Nick088 commited on
Commit
b23d86c
1 Parent(s): b00ccf5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
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']
10
+
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
+ gr.Interface(fn=text_to_speech, inputs=["text", "text"], outputs="audio").launch()