Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -2,10 +2,10 @@ import gradio as gr
|
|
2 |
from TTS.api import TTS
|
3 |
|
4 |
# Init TTS
|
5 |
-
tts = TTS(model_name="tts_models/multilingual/multi-dataset/your_tts", progress_bar
|
6 |
zh_tts = TTS(model_name="tts_models/zh-CN/baker/tacotron2-DDC-GST", progress_bar=False, gpu=False)
|
7 |
-
de_tts = TTS(model_name
|
8 |
-
es_tts = TTS(model_name
|
9 |
|
10 |
def text_to_speech(text: str, speaker_wav, speaker_wav_file, language: str):
|
11 |
if speaker_wav_file and not speaker_wav:
|
@@ -33,7 +33,7 @@ def text_to_speech(text: str, speaker_wav, speaker_wav_file, language: str):
|
|
33 |
tts.tts_to_file(text, speaker=tts.speakers[0], language=language, file_path=file_path)
|
34 |
return file_path
|
35 |
|
36 |
-
|
37 |
|
38 |
# inputs = [gr.Textbox(label="Input the text", value="", max_lines=3),
|
39 |
# gr.Audio(label="Voice to clone", source="microphone", type="filepath"),
|
@@ -61,6 +61,8 @@ def handle_language_change(choice):
|
|
61 |
else:
|
62 |
return gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
|
63 |
|
|
|
|
|
64 |
with gr.Blocks() as demo:
|
65 |
with gr.Row():
|
66 |
with gr.Column():
|
@@ -70,12 +72,14 @@ with gr.Blocks() as demo:
|
|
70 |
audio_input_mic = gr.Audio(label="Voice to clone", source="microphone", type="filepath", visible=True)
|
71 |
audio_input_file = gr.Audio(label="Voice to clone", type="filepath", visible=False)
|
72 |
lan_input = gr.Radio(label="Language", choices=["en", "zh-CN", "fr-fr", "pt-br", "de", "es"], value="en")
|
|
|
|
|
|
|
73 |
with gr.Column():
|
74 |
audio_output = gr.Audio(label="Output")
|
75 |
|
76 |
# gr.Examples(examples, fn=inference, inputs=[audio_file, text_input],
|
77 |
# outputs=audio_output, cache_examples=True)
|
78 |
-
btn = gr.Button("Submit")
|
79 |
btn.click(text_to_speech, inputs=[text_input, audio_input_mic,
|
80 |
audio_input_file, lan_input], outputs=audio_output)
|
81 |
radio.change(toggle, radio, [audio_input_mic, audio_input_file])
|
|
|
2 |
from TTS.api import TTS
|
3 |
|
4 |
# Init TTS
|
5 |
+
tts = TTS(model_name="tts_models/multilingual/multi-dataset/your_tts", progress_bar=False, gpu=False)
|
6 |
zh_tts = TTS(model_name="tts_models/zh-CN/baker/tacotron2-DDC-GST", progress_bar=False, gpu=False)
|
7 |
+
de_tts = TTS(model_name="tts_models/de/thorsten/vits", gpu=False)
|
8 |
+
es_tts = TTS(model_name="tts_models/es/mai/tacotron2-DDC", progress_bar=False, gpu=False)
|
9 |
|
10 |
def text_to_speech(text: str, speaker_wav, speaker_wav_file, language: str):
|
11 |
if speaker_wav_file and not speaker_wav:
|
|
|
33 |
tts.tts_to_file(text, speaker=tts.speakers[0], language=language, file_path=file_path)
|
34 |
return file_path
|
35 |
|
36 |
+
|
37 |
|
38 |
# inputs = [gr.Textbox(label="Input the text", value="", max_lines=3),
|
39 |
# gr.Audio(label="Voice to clone", source="microphone", type="filepath"),
|
|
|
61 |
else:
|
62 |
return gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
|
63 |
|
64 |
+
warming_text = """Please note that Chinese, German, and Spanish are currently not supported for voice cloning."""
|
65 |
+
|
66 |
with gr.Blocks() as demo:
|
67 |
with gr.Row():
|
68 |
with gr.Column():
|
|
|
72 |
audio_input_mic = gr.Audio(label="Voice to clone", source="microphone", type="filepath", visible=True)
|
73 |
audio_input_file = gr.Audio(label="Voice to clone", type="filepath", visible=False)
|
74 |
lan_input = gr.Radio(label="Language", choices=["en", "zh-CN", "fr-fr", "pt-br", "de", "es"], value="en")
|
75 |
+
gradio.Markdown(warming_text)
|
76 |
+
|
77 |
+
btn = gr.Button("Submit")
|
78 |
with gr.Column():
|
79 |
audio_output = gr.Audio(label="Output")
|
80 |
|
81 |
# gr.Examples(examples, fn=inference, inputs=[audio_file, text_input],
|
82 |
# outputs=audio_output, cache_examples=True)
|
|
|
83 |
btn.click(text_to_speech, inputs=[text_input, audio_input_mic,
|
84 |
audio_input_file, lan_input], outputs=audio_output)
|
85 |
radio.change(toggle, radio, [audio_input_mic, audio_input_file])
|