Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -35,14 +35,11 @@ def change_aud(text: str, speaker_wav, speaker_wav_file):
|
|
35 |
return file_path
|
36 |
|
37 |
def show_error(text):
|
38 |
-
if
|
39 |
-
return gr.update(visible=True), gr.update(visible=False)
|
40 |
else:
|
41 |
return gr.update(visible=False), gr.update(visible=True)
|
42 |
|
43 |
-
def clear_color(text_input, radio):
|
44 |
-
return gr.update(elem_id="alert"), gr.update(value="mic")
|
45 |
-
|
46 |
title = "Voice-Cloning-Demo"
|
47 |
|
48 |
def toggle(choice):
|
@@ -50,13 +47,16 @@ def toggle(choice):
|
|
50 |
return gr.update(visible=True, value=None), gr.update(visible=False, value=None)
|
51 |
else:
|
52 |
return gr.update(visible=False, value=None), gr.update(visible=True, value=None)
|
53 |
-
|
54 |
def change_color(text_input):
|
55 |
if len(text_input) == 0:
|
56 |
return gr.update(elem_id="warning", autofocus=True)
|
57 |
else:
|
58 |
return gr.update(elem_id="alert", autofocus=False)
|
59 |
|
|
|
|
|
|
|
|
|
60 |
with gr.Blocks(css=css) as demo:
|
61 |
with gr.Row():
|
62 |
with gr.Column():
|
@@ -72,16 +72,14 @@ with gr.Blocks(css=css) as demo:
|
|
72 |
with gr.Column():
|
73 |
btn = gr.Button("Submit", variant="primary")
|
74 |
with gr.Column():
|
75 |
-
audio_output = gr.Audio(label="Output", visible=True)
|
76 |
-
error_box = gr.Textbox(label="WARNING", value="Input box cannot be blank!!", visible=False,
|
77 |
|
78 |
-
|
79 |
-
# outputs=audio_output, cache_examples=True)
|
80 |
btn.click(text_to_speech, inputs=[text_input, audio_input_mic, audio_input_file], outputs=audio_output)
|
81 |
btn.click(show_error, text_input, [error_box, audio_output])
|
82 |
radio.change(toggle, radio, [audio_input_mic, audio_input_file])
|
83 |
-
btn_clear.click(clear_color, [text_input, radio], [text_input, radio])
|
84 |
-
btn_clear.add(audio_output)
|
85 |
btn.click(change_color, text_input, text_input)
|
86 |
|
87 |
demo.launch()
|
|
|
35 |
return file_path
|
36 |
|
37 |
def show_error(text):
|
38 |
+
if text == "":
|
39 |
+
return gr.update(visible=True, elem_id="warning", elem_classes="feedback"), gr.update(visible=False)
|
40 |
else:
|
41 |
return gr.update(visible=False), gr.update(visible=True)
|
42 |
|
|
|
|
|
|
|
43 |
title = "Voice-Cloning-Demo"
|
44 |
|
45 |
def toggle(choice):
|
|
|
47 |
return gr.update(visible=True, value=None), gr.update(visible=False, value=None)
|
48 |
else:
|
49 |
return gr.update(visible=False, value=None), gr.update(visible=True, value=None)
|
|
|
50 |
def change_color(text_input):
|
51 |
if len(text_input) == 0:
|
52 |
return gr.update(elem_id="warning", autofocus=True)
|
53 |
else:
|
54 |
return gr.update(elem_id="alert", autofocus=False)
|
55 |
|
56 |
+
def clear_color(text_input, radio,error_box):
|
57 |
+
return gr.update(elem_id="alert"), gr.update(value="mic"), gr.update(visible=False)
|
58 |
+
|
59 |
+
|
60 |
with gr.Blocks(css=css) as demo:
|
61 |
with gr.Row():
|
62 |
with gr.Column():
|
|
|
72 |
with gr.Column():
|
73 |
btn = gr.Button("Submit", variant="primary")
|
74 |
with gr.Column():
|
75 |
+
audio_output = gr.Audio(label="Output", visible=True, autoplay=True)
|
76 |
+
error_box = gr.Textbox(label="WARNING", value="Input box cannot be blank!!", visible=False, container=True)
|
77 |
|
78 |
+
btn_clear.add(audio_output)
|
|
|
79 |
btn.click(text_to_speech, inputs=[text_input, audio_input_mic, audio_input_file], outputs=audio_output)
|
80 |
btn.click(show_error, text_input, [error_box, audio_output])
|
81 |
radio.change(toggle, radio, [audio_input_mic, audio_input_file])
|
82 |
+
btn_clear.click(clear_color, [text_input, radio, error_box], [text_input, radio, error_box])
|
|
|
83 |
btn.click(change_color, text_input, text_input)
|
84 |
|
85 |
demo.launch()
|