coraKong commited on
Commit
f47a772
1 Parent(s): 96339a8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -8
app.py CHANGED
@@ -35,13 +35,50 @@ def text_to_speech(text: str, speaker_wav, speaker_wav_file, language: str):
35
 
36
  intro_text = """Please note that Chinese, German, and Spanish are currently not supported for voice cloning."""
37
 
38
- inputs = [gr.Textbox(label="Input the text", value="", max_lines=3),
39
- gr.Audio(label="Voice to clone", source="microphone", type="filepath"),
40
- gr.Audio(label="Voice to clone", type="filepath"),
41
- gr.Radio(label="Language", choices=["en", "zh-CN", "fr-fr", "pt-br", "de", "es"], value="en"),
42
- gr.Text(intro_text, font_size=14)]
43
- outputs = gr.Audio(label="Output")
44
 
45
- demo = gr.Interface(fn=text_to_speech, inputs=inputs, outputs=outputs)
46
 
47
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
  intro_text = """Please note that Chinese, German, and Spanish are currently not supported for voice cloning."""
37
 
38
+ # inputs = [gr.Textbox(label="Input the text", value="", max_lines=3),
39
+ # gr.Audio(label="Voice to clone", source="microphone", type="filepath"),
40
+ # gr.Audio(label="Voice to clone", type="filepath"),
41
+ # gr.Radio(label="Language", choices=["en", "zh-CN", "fr-fr", "pt-br", "de", "es"], value="en"),
42
+ # gr.Text(intro_text, font_size=14)]
43
+ # outputs = gr.Audio(label="Output")
44
 
45
+ # demo = gr.Interface(fn=text_to_speech, inputs=inputs, outputs=outputs)
46
 
47
+ # demo.launch()
48
+
49
+
50
+ title = "Voice-Cloning-Demo"
51
+
52
+ def toggle(choice):
53
+ if choice == "mic":
54
+ return gr.update(visible=True, value=None), gr.update(visible=False, value=None)
55
+ else:
56
+ return gr.update(visible=False, value=None), gr.update(visible=True, value=None)
57
+
58
+ def handle_language_change(choice):
59
+ if choice == "zh-CN" or choice == "de" or choice == "es":
60
+ return gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
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():
67
+ text_input = gr.Textbox(label="Input the text", value="", max_lines=3)
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", 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])
82
+ lan_input.change(handle_language_change, lan_input, [radio, audio_input_mic, audio_input_file])
83
+
84
+ demo.launch(enable_queue=True)