Update app.py
Browse files
app.py
CHANGED
@@ -1,26 +1,20 @@
|
|
1 |
import gradio as gr
|
2 |
from infer_onnx import TTS
|
3 |
|
4 |
-
|
5 |
-
|
|
|
6 |
|
7 |
|
8 |
def text_to_speech(model_name, text):
|
9 |
-
|
10 |
-
|
11 |
-
audio = natasha(text)
|
12 |
-
natasha.save_wav(audio, 'temp.wav')
|
13 |
|
14 |
-
if model_name == "TeraTTS/glados-vits":
|
15 |
-
audio = glados(text)
|
16 |
-
glados.save_wav(audio, 'temp.wav')
|
17 |
-
|
18 |
return 'temp.wav'
|
19 |
|
20 |
input_text = gr.Textbox(label="Введите текст для синтеза речи")
|
21 |
-
model_choice = gr.Dropdown(choices=
|
22 |
output_audio = gr.Audio(label="Аудио", type="numpy")
|
23 |
|
24 |
-
iface = gr.Interface(fn=text_to_speech, inputs=[model_choice, input_text], outputs=output_audio
|
25 |
-
description="## [Ссылка](https://github.com/Tera2Space/RUTTS/) на наш гитхаб с кодом для локального запуска")
|
26 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from infer_onnx import TTS
|
3 |
|
4 |
+
models = ["TeraTTS/natasha-vits", "TeraTTS/glados-vits", "TeraTTS/glados2-vits"]
|
5 |
+
|
6 |
+
models = {k:TTS(k) for k in models}
|
7 |
|
8 |
|
9 |
def text_to_speech(model_name, text):
|
10 |
+
audio = models[model_name](text)
|
11 |
+
models[model_name].save_wav(audio, 'temp.wav')
|
|
|
|
|
12 |
|
|
|
|
|
|
|
|
|
13 |
return 'temp.wav'
|
14 |
|
15 |
input_text = gr.Textbox(label="Введите текст для синтеза речи")
|
16 |
+
model_choice = gr.Dropdown(choices=list(models.keys()), value="TeraTTS/natasha-vits", label="Выберите модель")
|
17 |
output_audio = gr.Audio(label="Аудио", type="numpy")
|
18 |
|
19 |
+
iface = gr.Interface(fn=text_to_speech, inputs=[model_choice, input_text], outputs=output_audio)
|
|
|
20 |
iface.launch()
|