Update app.py
Browse files
app.py
CHANGED
@@ -3,50 +3,25 @@ import os
|
|
3 |
from TTS.api import TTS
|
4 |
import time
|
5 |
|
|
|
|
|
6 |
|
7 |
-
|
8 |
-
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.
|
9 |
-
https://dl.fbaipublicfiles.com/mms/tts/all-tts-languages.html
|
10 |
-
"""
|
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 |
-
api_fas = TTS(f"tts_models/fas/fairseq/vits", gpu=False) # Persian
|
16 |
-
api_tur = TTS(f"tts_models/tur/fairseq/vits", gpu=False) # Turkish
|
17 |
-
api_deu = TTS(f"tts_models/deu/fairseq/vits", gpu=False) # German, Standard
|
18 |
-
api_ara = TTS(f"tts_models/ara/fairseq/vits", gpu=False) # Arabic
|
19 |
-
api_por = TTS(f"tts_models/por/fairseq/vits", gpu=False) # Portuguese
|
20 |
-
api_hin = TTS(f"tts_models/hin/fairseq/vits", gpu=False) # Hindi
|
21 |
-
|
22 |
-
|
23 |
-
def audio_tts(txt, language, audio_file):
|
24 |
|
25 |
# TTS with on the fly voice conversion
|
26 |
print(f"Language: {language}")
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
api_fas.tts_with_vc_to_file(txt, speaker_wav=audio_file, file_path="ouptut.wav")
|
35 |
-
elif language == "tur":
|
36 |
-
api_tur.tts_with_vc_to_file(txt, speaker_wav=audio_file, file_path="ouptut.wav")
|
37 |
-
elif language == "deu":
|
38 |
-
api_deu.tts_with_vc_to_file(txt, speaker_wav=audio_file, file_path="ouptut.wav")
|
39 |
-
elif language == "ara":
|
40 |
-
api_ara.tts_with_vc_to_file(txt, speaker_wav=audio_file, file_path="ouptut.wav")
|
41 |
-
elif language == "por":
|
42 |
-
api_por.tts_with_vc_to_file(txt, speaker_wav=audio_file, file_path="ouptut.wav")
|
43 |
-
elif language == "hin":
|
44 |
-
api_hin.tts_with_vc_to_file(txt, speaker_wav=audio_file, file_path="ouptut.wav")
|
45 |
return "ouptut.wav"
|
46 |
|
47 |
|
48 |
demo = gr.Interface(fn=audio_tts, inputs=[gr.Textbox(label="Input text TTS", value="Привет! Я Макс."),
|
49 |
-
gr.Dropdown(choices=["
|
50 |
label="Language", value="rus"),
|
51 |
gr.Audio(source="upload", type="filepath", label="Input audio")],
|
52 |
outputs=gr.Audio(source="upload", type="filepath", label="Output audio"))
|
|
|
3 |
from TTS.api import TTS
|
4 |
import time
|
5 |
|
6 |
+
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v1")
|
7 |
+
tts.to("cpu")
|
8 |
|
9 |
+
def audio_tts(prompt, language, speaker_wav):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
# TTS with on the fly voice conversion
|
12 |
print(f"Language: {language}")
|
13 |
+
tts.tts_to_file(
|
14 |
+
text=prompt,
|
15 |
+
file_path="output.wav",
|
16 |
+
speaker_wav=speaker_wav,
|
17 |
+
language=language,
|
18 |
+
gpu=False,
|
19 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
return "ouptut.wav"
|
21 |
|
22 |
|
23 |
demo = gr.Interface(fn=audio_tts, inputs=[gr.Textbox(label="Input text TTS", value="Привет! Я Макс."),
|
24 |
+
gr.Dropdown(choices=["ru", "en", "es", "fa", "tr", "de", "ar", "pt", "hi"],
|
25 |
label="Language", value="rus"),
|
26 |
gr.Audio(source="upload", type="filepath", label="Input audio")],
|
27 |
outputs=gr.Audio(source="upload", type="filepath", label="Output audio"))
|