firzaelbuho
commited on
Commit
•
64ef07b
1
Parent(s):
b1fc351
Update app2.py
Browse files
app2.py
CHANGED
@@ -63,6 +63,7 @@ def create_vc_fn(model_name, tgt_sr, net_g, vc, if_f0, version, file_index):
|
|
63 |
vc_upload,
|
64 |
tts_text,
|
65 |
tts_voice,
|
|
|
66 |
f0_up_key,
|
67 |
f0_method,
|
68 |
index_rate,
|
@@ -95,7 +96,13 @@ def create_vc_fn(model_name, tgt_sr, net_g, vc, if_f0, version, file_index):
|
|
95 |
return "Text is too long", None
|
96 |
if tts_text is None or tts_voice is None:
|
97 |
return "You need to enter text and select a voice", None
|
98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
audio, sr = librosa.load("tts.mp3", sr=16000, mono=True)
|
100 |
vc_input = "tts.mp3"
|
101 |
times = [0, 0, 0]
|
@@ -337,7 +344,8 @@ def change_audio_mode(vc_audio_mode):
|
|
337 |
gr.Button.update(visible=False),
|
338 |
# TTS
|
339 |
gr.Textbox.update(visible=False),
|
340 |
-
gr.Dropdown.update(visible=False)
|
|
|
341 |
)
|
342 |
elif vc_audio_mode == "Upload audio":
|
343 |
return (
|
@@ -363,7 +371,8 @@ def change_audio_mode(vc_audio_mode):
|
|
363 |
gr.Button.update(visible=False),
|
364 |
# TTS
|
365 |
gr.Textbox.update(visible=False),
|
366 |
-
gr.Dropdown.update(visible=False)
|
|
|
367 |
)
|
368 |
elif vc_audio_mode == "Youtube":
|
369 |
return (
|
@@ -389,7 +398,8 @@ def change_audio_mode(vc_audio_mode):
|
|
389 |
gr.Button.update(visible=True),
|
390 |
# TTS
|
391 |
gr.Textbox.update(visible=False),
|
392 |
-
gr.Dropdown.update(visible=False)
|
|
|
393 |
)
|
394 |
elif vc_audio_mode == "TTS Audio":
|
395 |
return (
|
@@ -415,7 +425,8 @@ def change_audio_mode(vc_audio_mode):
|
|
415 |
gr.Button.update(visible=False),
|
416 |
# TTS
|
417 |
gr.Textbox.update(visible=True),
|
418 |
-
gr.Dropdown.update(visible=True)
|
|
|
419 |
)
|
420 |
|
421 |
def use_microphone(microphone):
|
@@ -630,6 +641,7 @@ if __name__ == '__main__':
|
|
630 |
# TTS
|
631 |
tts_text = gr.Textbox(label="TTS text", info="Text to speech input", visible=False)
|
632 |
tts_voice = gr.Dropdown(label="Edge-tts speaker", choices=voices, visible=False, allow_custom_value=False, value="en-US-AnaNeural-Female")
|
|
|
633 |
with gr.Column():
|
634 |
vc_split_model = gr.Dropdown(label="Splitter Model", choices=["hdemucs_mmi", "htdemucs", "htdemucs_ft", "mdx", "mdx_q", "mdx_extra_q"], allow_custom_value=False, visible=False, value="htdemucs", info="Select the splitter model (Default: htdemucs)")
|
635 |
vc_split_log = gr.Textbox(label="Output Information", visible=False, interactive=False)
|
@@ -877,7 +889,8 @@ if __name__ == '__main__':
|
|
877 |
vc_combined_output,
|
878 |
vc_combine,
|
879 |
tts_text,
|
880 |
-
tts_voice
|
|
|
881 |
]
|
882 |
)
|
883 |
# Audio tool
|
|
|
63 |
vc_upload,
|
64 |
tts_text,
|
65 |
tts_voice,
|
66 |
+
tts_rate,
|
67 |
f0_up_key,
|
68 |
f0_method,
|
69 |
index_rate,
|
|
|
96 |
return "Text is too long", None
|
97 |
if tts_text is None or tts_voice is None:
|
98 |
return "You need to enter text and select a voice", None
|
99 |
+
inc_rate = "+0%"
|
100 |
+
if tts_rate < 0 :
|
101 |
+
inc_rate = (f"{100 - tts_rate}%")
|
102 |
+
else:
|
103 |
+
inc_rate = (f"+{tts_rate - s100}%")
|
104 |
+
|
105 |
+
asyncio.run(edge_tts.Communicate(text=tts_text, voice= "-".join(tts_voice.split('-')[:-1]), rate= "-80%").save("tts.mp3"))
|
106 |
audio, sr = librosa.load("tts.mp3", sr=16000, mono=True)
|
107 |
vc_input = "tts.mp3"
|
108 |
times = [0, 0, 0]
|
|
|
344 |
gr.Button.update(visible=False),
|
345 |
# TTS
|
346 |
gr.Textbox.update(visible=False),
|
347 |
+
gr.Dropdown.update(visible=False),
|
348 |
+
gr.Number.update(visible=False)
|
349 |
)
|
350 |
elif vc_audio_mode == "Upload audio":
|
351 |
return (
|
|
|
371 |
gr.Button.update(visible=False),
|
372 |
# TTS
|
373 |
gr.Textbox.update(visible=False),
|
374 |
+
gr.Dropdown.update(visible=False),
|
375 |
+
gr.Number.update(visible=False)
|
376 |
)
|
377 |
elif vc_audio_mode == "Youtube":
|
378 |
return (
|
|
|
398 |
gr.Button.update(visible=True),
|
399 |
# TTS
|
400 |
gr.Textbox.update(visible=False),
|
401 |
+
gr.Dropdown.update(visible=False),
|
402 |
+
gr.Number.update(visible=False)
|
403 |
)
|
404 |
elif vc_audio_mode == "TTS Audio":
|
405 |
return (
|
|
|
425 |
gr.Button.update(visible=False),
|
426 |
# TTS
|
427 |
gr.Textbox.update(visible=True),
|
428 |
+
gr.Dropdown.update(visible=True),
|
429 |
+
gr.Textbox.update(visible=True)
|
430 |
)
|
431 |
|
432 |
def use_microphone(microphone):
|
|
|
641 |
# TTS
|
642 |
tts_text = gr.Textbox(label="TTS text", info="Text to speech input", visible=False)
|
643 |
tts_voice = gr.Dropdown(label="Edge-tts speaker", choices=voices, visible=False, allow_custom_value=False, value="en-US-AnaNeural-Female")
|
644 |
+
tts_rate = gr.Textbox(label="TTS Rate", info='Change tts output speed (100 = normal)')
|
645 |
with gr.Column():
|
646 |
vc_split_model = gr.Dropdown(label="Splitter Model", choices=["hdemucs_mmi", "htdemucs", "htdemucs_ft", "mdx", "mdx_q", "mdx_extra_q"], allow_custom_value=False, visible=False, value="htdemucs", info="Select the splitter model (Default: htdemucs)")
|
647 |
vc_split_log = gr.Textbox(label="Output Information", visible=False, interactive=False)
|
|
|
889 |
vc_combined_output,
|
890 |
vc_combine,
|
891 |
tts_text,
|
892 |
+
tts_voice,
|
893 |
+
tts_rate
|
894 |
]
|
895 |
)
|
896 |
# Audio tool
|