Update app.py
Browse files
app.py
CHANGED
@@ -5,6 +5,13 @@ import time
|
|
5 |
|
6 |
count = 0
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
def audio_tts(txt, language, audio_file):
|
10 |
global count
|
@@ -15,13 +22,17 @@ def audio_tts(txt, language, audio_file):
|
|
15 |
count = 0
|
16 |
|
17 |
# TTS with on the fly voice conversion
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
20 |
return "ouptut.wav"
|
21 |
|
22 |
|
23 |
demo = gr.Interface(fn=audio_tts, inputs=[gr.Textbox(label="Input text TTS", value="Привет! Я Макс."),
|
24 |
-
gr.
|
25 |
gr.Audio(source="upload", type="filepath", label="Input audio")],
|
26 |
outputs=gr.Audio(source="upload", type="filepath", label="Output audio"))
|
27 |
|
|
|
5 |
|
6 |
count = 0
|
7 |
|
8 |
+
"""
|
9 |
+
For Fairseq models, use the following name format: tts_models/<lang-iso_code>/fairseq/vits. You can find the language ISO codes here and learn about the Fairseq models here.
|
10 |
+
https://dl.fbaipublicfiles.com/mms/tts/all-tts-languages.html
|
11 |
+
"""
|
12 |
+
api_rus = TTS(f"tts_models/rus/fairseq/vits", gpu=False)
|
13 |
+
api_eng = TTS(f"tts_models/eng/fairseq/vits", gpu=False)
|
14 |
+
api_spa = TTS(f"tts_models/spa/fairseq/vits", gpu=False)
|
15 |
|
16 |
def audio_tts(txt, language, audio_file):
|
17 |
global count
|
|
|
22 |
count = 0
|
23 |
|
24 |
# TTS with on the fly voice conversion
|
25 |
+
if language == "rus":
|
26 |
+
api_rus.tts_with_vc_to_file(txt, speaker_wav=audio_file, file_path="ouptut.wav")
|
27 |
+
elif language == "eng":
|
28 |
+
api_eng.tts_with_vc_to_file(txt, speaker_wav=audio_file, file_path="ouptut.wav")
|
29 |
+
elif language == "spa":
|
30 |
+
api_spa.tts_with_vc_to_file(txt, speaker_wav=audio_file, file_path="ouptut.wav")
|
31 |
return "ouptut.wav"
|
32 |
|
33 |
|
34 |
demo = gr.Interface(fn=audio_tts, inputs=[gr.Textbox(label="Input text TTS", value="Привет! Я Макс."),
|
35 |
+
gr.Dropdown(choices=["rus", "eng", "spa"],label="Language", value="rus"),
|
36 |
gr.Audio(source="upload", type="filepath", label="Input audio")],
|
37 |
outputs=gr.Audio(source="upload", type="filepath", label="Output audio"))
|
38 |
|