Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -43,7 +43,8 @@ model.eval()
|
|
43 |
|
44 |
|
45 |
async def text_to_speech(text: str, output_file="output.mp3"):
|
46 |
-
|
|
|
47 |
communicate = edge_tts.Communicate(text, voice)
|
48 |
await communicate.save(output_file)
|
49 |
return output_file
|
@@ -95,7 +96,7 @@ def generate(
|
|
95 |
|
96 |
if is_tts:
|
97 |
output_file = asyncio.run(text_to_speech(final_response))
|
98 |
-
yield output_file # Return
|
99 |
else:
|
100 |
yield final_response # Return text response
|
101 |
|
|
|
43 |
|
44 |
|
45 |
async def text_to_speech(text: str, output_file="output.mp3"):
|
46 |
+
"""Convert text to speech using Edge TTS and save as MP3"""
|
47 |
+
voice = "en-US-JennyNeural" # Change this to your preferred voice
|
48 |
communicate = edge_tts.Communicate(text, voice)
|
49 |
await communicate.save(output_file)
|
50 |
return output_file
|
|
|
96 |
|
97 |
if is_tts:
|
98 |
output_file = asyncio.run(text_to_speech(final_response))
|
99 |
+
yield gr.Audio(output_file, autoplay=True) # Return playable audio
|
100 |
else:
|
101 |
yield final_response # Return text response
|
102 |
|