Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
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=False, gpu=False)
|
6 |
zh_tts = TTS(model_name="tts_models/zh-CN/baker/tacotron2-DDC-GST", progress_bar=False, gpu=False)
|
@@ -49,6 +50,13 @@ def handle_language_change(choice):
|
|
49 |
else:
|
50 |
return gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
|
51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
warming_text = """Please note that Chinese, German, and Spanish are currently not supported for voice cloning."""
|
53 |
|
54 |
with gr.Blocks() as demo:
|
@@ -59,23 +67,23 @@ with gr.Blocks() as demo:
|
|
59 |
gr.Markdown(warming_text)
|
60 |
radio = gr.Radio(["mic", "file"], value="mic",
|
61 |
label="How would you like to upload your audio?")
|
62 |
-
audio_input_mic = gr.Audio(label="Voice to clone",
|
63 |
audio_input_file = gr.Audio(label="Voice to clone", type="filepath", visible=False)
|
64 |
|
65 |
with gr.Row():
|
66 |
with gr.Column():
|
67 |
btn_clear = gr.Button("Clear")
|
68 |
with gr.Column():
|
69 |
-
btn = gr.Button("Submit", variant="primary")
|
70 |
with gr.Column():
|
71 |
audio_output = gr.Audio(label="Output")
|
72 |
|
73 |
# gr.Examples(examples, fn=inference, inputs=[audio_file, text_input],
|
74 |
# outputs=audio_output, cache_examples=True)
|
75 |
-
|
76 |
-
|
77 |
-
audio_input_file, lan_input], outputs=audio_output)
|
78 |
radio.change(toggle, radio, [audio_input_mic, audio_input_file])
|
79 |
lan_input.change(handle_language_change, lan_input, [radio, audio_input_mic, audio_input_file])
|
|
|
80 |
|
81 |
-
demo.launch(
|
|
|
1 |
import gradio as gr
|
2 |
from TTS.api import TTS
|
3 |
|
4 |
+
|
5 |
# Init TTS
|
6 |
tts = TTS(model_name="tts_models/multilingual/multi-dataset/your_tts", progress_bar=False, gpu=False)
|
7 |
zh_tts = TTS(model_name="tts_models/zh-CN/baker/tacotron2-DDC-GST", progress_bar=False, gpu=False)
|
|
|
50 |
else:
|
51 |
return gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
|
52 |
|
53 |
+
def btn_input(text_input):
|
54 |
+
if len(text_input) > 0:
|
55 |
+
new_btn = gr.Button("Submit", variant="primary", interactive=True)
|
56 |
+
else:
|
57 |
+
new_btn = gr.Button("Submit", variant="primary", interactive=False)
|
58 |
+
return new_btn
|
59 |
+
|
60 |
warming_text = """Please note that Chinese, German, and Spanish are currently not supported for voice cloning."""
|
61 |
|
62 |
with gr.Blocks() as demo:
|
|
|
67 |
gr.Markdown(warming_text)
|
68 |
radio = gr.Radio(["mic", "file"], value="mic",
|
69 |
label="How would you like to upload your audio?")
|
70 |
+
audio_input_mic = gr.Audio(label="Voice to clone", sources="microphone", type="filepath", visible=True)
|
71 |
audio_input_file = gr.Audio(label="Voice to clone", type="filepath", visible=False)
|
72 |
|
73 |
with gr.Row():
|
74 |
with gr.Column():
|
75 |
btn_clear = gr.Button("Clear")
|
76 |
with gr.Column():
|
77 |
+
btn = gr.Button("Submit", variant="primary", interactive=False)
|
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])
|
86 |
lan_input.change(handle_language_change, lan_input, [radio, audio_input_mic, audio_input_file])
|
87 |
+
text_input.change(btn_input, text_input, btn)
|
88 |
|
89 |
+
demo.launch(share=True)
|