prithivMLmods commited on
Commit
7f471f2
·
verified ·
1 Parent(s): b06a87f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -43,7 +43,8 @@ model.eval()
43
 
44
 
45
  async def text_to_speech(text: str, output_file="output.mp3"):
46
- voice = "en-US-JennyNeural"
 
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 MP3 file
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