ysharma HF staff commited on
Commit
e92c6df
1 Parent(s): 7d0efdb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -7
app.py CHANGED
@@ -9,7 +9,7 @@ def tts(text, model, voice, api_key):
9
  raise gr.Error('Please enter your OpenAI API Key')
10
  else:
11
  try:
12
- client = openai.OpenAI(api_key=api_key)
13
 
14
  response = client.audio.speech.create(
15
  model='tts-1', # "tts-1","tts-1-hd"
@@ -22,12 +22,6 @@ def tts(text, model, voice, api_key):
22
  raise gr.Error("An error occurred while generating speech. Please check your API key and try again.")
23
  print(str(error))
24
 
25
- response = client.audio.speech.create(
26
- model=model, # expected values: "tts-1","tts-1-hd"
27
- voice=voice, # expected values: 'alloy', 'echo', 'fable', 'onyx', 'nova', 'shimmer'
28
- input=text,
29
- )
30
-
31
  # Create a temp file to save the audio
32
  with tempfile.NamedTemporaryFile(suffix=".mp3", delete=False) as temp_file:
33
  temp_file.write(response.content)
 
9
  raise gr.Error('Please enter your OpenAI API Key')
10
  else:
11
  try:
12
+ client = OpenAI(api_key=api_key)
13
 
14
  response = client.audio.speech.create(
15
  model='tts-1', # "tts-1","tts-1-hd"
 
22
  raise gr.Error("An error occurred while generating speech. Please check your API key and try again.")
23
  print(str(error))
24
 
 
 
 
 
 
 
25
  # Create a temp file to save the audio
26
  with tempfile.NamedTemporaryFile(suffix=".mp3", delete=False) as temp_file:
27
  temp_file.write(response.content)