jonathanagustin commited on
Commit
2449b0e
1 Parent(s): c0ae2ab

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +17 -7
app.py CHANGED
@@ -32,23 +32,33 @@ def tts(input_text: str, model: str, voice: str, api_key: str) -> str:
32
  voice=voice,
33
  model=model
34
  )
35
- except openai.Timeout as e:
 
36
  raise gr.Error(f"OpenAI API request timed out: {e}")
37
- except openai.APIError as e:
38
- raise gr.Error(f"OpenAI API returned an API Error: {e}")
39
  except openai.APIConnectionError as e:
40
  raise gr.Error(f"OpenAI API request failed to connect: {e}")
41
- except openai.InvalidRequestError as e:
42
- raise gr.Error(f"OpenAI API request was invalid: {e}")
43
  except openai.AuthenticationError as e:
44
  raise gr.Error(f"OpenAI API request was not authorized: {e}")
45
- except openai.PermissionError as e:
46
  raise gr.Error(f"OpenAI API request was not permitted: {e}")
47
  except openai.RateLimitError as e:
48
  raise gr.Error(f"OpenAI API request exceeded rate limit: {e}")
49
- except openai.OpenAIError as e:
 
 
 
 
 
 
 
 
 
50
  raise gr.Error(f"OpenAI API Error: {e}")
 
 
 
51
  except Exception as e:
 
52
  raise gr.Error(f"An unexpected error occurred: {e}")
53
 
54
  if not hasattr(response, 'audio'):
 
32
  voice=voice,
33
  model=model
34
  )
35
+
36
+ except openai.APITimeoutError as e:
37
  raise gr.Error(f"OpenAI API request timed out: {e}")
 
 
38
  except openai.APIConnectionError as e:
39
  raise gr.Error(f"OpenAI API request failed to connect: {e}")
 
 
40
  except openai.AuthenticationError as e:
41
  raise gr.Error(f"OpenAI API request was not authorized: {e}")
42
+ except openai.PermissionDeniedError as e:
43
  raise gr.Error(f"OpenAI API request was not permitted: {e}")
44
  except openai.RateLimitError as e:
45
  raise gr.Error(f"OpenAI API request exceeded rate limit: {e}")
46
+ except openai.BadRequestError as e:
47
+ raise gr.Error(f"OpenAI API bad request: {e}")
48
+ except openai.UnprocessableEntityError as e:
49
+ raise gr.Error(f"OpenAI API request could not be processed: {e}")
50
+ except openai.NotFoundError as e:
51
+ raise gr.Error(f"OpenAI API resource not found: {e}")
52
+ except openai.InternalServerError as e:
53
+ raise gr.Error(f"OpenAI API internal server error: {e}")
54
+ except openai.APIError as e:
55
+ # This will catch other API-related errors not captured above
56
  raise gr.Error(f"OpenAI API Error: {e}")
57
+ except openai.OpenAIError as e:
58
+ # Catch-all for any other OpenAI exceptions
59
+ raise gr.Error(f"An OpenAI error occurred: {e}")
60
  except Exception as e:
61
+ # Catch any other exceptions
62
  raise gr.Error(f"An unexpected error occurred: {e}")
63
 
64
  if not hasattr(response, 'audio'):