Spaces:
Runtime error
Runtime error
TheStinger
commited on
Commit
•
58385ea
1
Parent(s):
dd22ce8
Update app.py
Browse files
app.py
CHANGED
@@ -4,34 +4,34 @@ import gradio as gr
|
|
4 |
def select_app(app_name):
|
5 |
if app_name == 'App 1':
|
6 |
|
7 |
-
from tts_voice import tts_order_voice
|
8 |
-
import edge_tts
|
9 |
-
import gradio as gr
|
10 |
-
import tempfile
|
11 |
-
import anyio
|
12 |
-
|
13 |
-
language_dict = tts_order_voice
|
14 |
|
15 |
-
|
16 |
-
voice = language_dict[language_code]
|
17 |
-
communicate = edge_tts.Communicate(text, voice)
|
18 |
-
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp_file:
|
19 |
-
tmp_path = tmp_file.name
|
20 |
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
-
|
24 |
|
25 |
|
26 |
|
27 |
-
input_text = gr.inputs.Textbox(lines=5, label="Text")
|
28 |
-
output_text = gr.outputs.Textbox(label="Text input")
|
29 |
-
output_audio = gr.outputs.Audio(type="filepath", label="Audio output")
|
30 |
-
default_language = list(language_dict.keys())[0]
|
31 |
-
language = gr.inputs.Dropdown(choices=list(language_dict.keys()), default=default_language, label="Choose the language and the model")
|
32 |
|
33 |
|
34 |
-
interface = gr.Interface(fn=text_to_speech_edge, inputs=[input_text, language], outputs=[output_text, output_audio], title="Ilaria TTS 💖")
|
35 |
|
36 |
|
37 |
if __name__ == "__main__":
|
|
|
4 |
def select_app(app_name):
|
5 |
if app_name == 'App 1':
|
6 |
|
7 |
+
from tts_voice import tts_order_voice
|
8 |
+
import edge_tts
|
9 |
+
import gradio as gr
|
10 |
+
import tempfile
|
11 |
+
import anyio
|
|
|
|
|
12 |
|
13 |
+
language_dict = tts_order_voice
|
|
|
|
|
|
|
|
|
14 |
|
15 |
+
async def text_to_speech_edge(text, language_code):
|
16 |
+
voice = language_dict[language_code]
|
17 |
+
communicate = edge_tts.Communicate(text, voice)
|
18 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp_file:
|
19 |
+
tmp_path = tmp_file.name
|
20 |
+
|
21 |
+
await communicate.save(tmp_path)
|
22 |
|
23 |
+
return "Text input:{}".format(text), tmp_path
|
24 |
|
25 |
|
26 |
|
27 |
+
input_text = gr.inputs.Textbox(lines=5, label="Text")
|
28 |
+
output_text = gr.outputs.Textbox(label="Text input")
|
29 |
+
output_audio = gr.outputs.Audio(type="filepath", label="Audio output")
|
30 |
+
default_language = list(language_dict.keys())[0]
|
31 |
+
language = gr.inputs.Dropdown(choices=list(language_dict.keys()), default=default_language, label="Choose the language and the model")
|
32 |
|
33 |
|
34 |
+
interface = gr.Interface(fn=text_to_speech_edge, inputs=[input_text, language], outputs=[output_text, output_audio], title="Ilaria TTS 💖")
|
35 |
|
36 |
|
37 |
if __name__ == "__main__":
|