Nick088 commited on
Commit
207d168
1 Parent(s): 0824f08

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -3,6 +3,7 @@ import gradio as gr
3
  def text_to_speech(text, voice):
4
  import subprocess
5
  import audiosegment
 
6
 
7
  command = ['edge-tts', '--voice', voice, '--text', text,
8
  '--write-media', 'edge.mp3', '--write-subtitles', 'edge.vtt']
@@ -10,7 +11,11 @@ def text_to_speech(text, voice):
10
  result = subprocess.run(command, stdout=subprocess.PIPE, text=True)
11
  print(result.stdout)
12
 
 
 
 
 
13
 
14
- voice_options = ["en-US-JennyNeural", "en-US-GuyNeural"]
15
 
16
- gr.Interface(fn=text_to_speech, inputs=["text", gr.Dropdown(voice_options)], outputs="audio").launch()
 
3
  def text_to_speech(text, voice):
4
  import subprocess
5
  import audiosegment
6
+ from IPython.display import Audio, display
7
 
8
  command = ['edge-tts', '--voice', voice, '--text', text,
9
  '--write-media', 'edge.mp3', '--write-subtitles', 'edge.vtt']
 
11
  result = subprocess.run(command, stdout=subprocess.PIPE, text=True)
12
  print(result.stdout)
13
 
14
+ try:
15
+ display(Audio("edge.mp3", autoplay=True))
16
+ except Exception as e:
17
+ print("Error:", str(e))
18
 
19
+ voice = ["en-US-JennyNeural", "en-US-GuyNeural"]
20
 
21
+ gr.Interface(fn=text_to_speech, inputs=["text", gr.Dropdown(voice)], outputs="audio").launch()