Core23 commited on
Commit
59e4bc8
1 Parent(s): 513acf4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -10
app.py CHANGED
@@ -136,16 +136,15 @@ def generate_response(transcribed_text):
136
 
137
 
138
  def inference(text):
139
- tts = gTTS(text=text, lang='sw', tld='com.mx',slow=False)
140
- output_file = "tts_output.mp3"
141
- tts.save(output_file)
142
- return output_file
143
-
144
- def process_audio_and_respond(audio):
145
- text = transcribe(audio)
146
- response_text = generate_response(text)
147
- output_file = inference(response_text)
148
- return response_text, output_file
149
 
150
  demo = gr.Interface(
151
  process_audio_and_respond,
 
136
 
137
 
138
  def inference(text):
139
+ #client = openai.OpenAI(api_key='your_api_key')
140
+ response = client.audio.speech.create(
141
+ model="tts-1",
142
+ voice="alloy",
143
+ input=text
144
+ )
145
+ output_file = "tts_output.mp3"
146
+ response.stream_to_file(output_file)
147
+ return output_file
 
148
 
149
  demo = gr.Interface(
150
  process_audio_and_respond,