Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -432,7 +432,11 @@ def get_tts_wav(ref_wav_path, prompt_text, prompt_language, text, text_language,
|
|
| 432 |
if (text[-1] not in splits): text += "。" if text_language != "en" else "."
|
| 433 |
print(("\n🎈实际输入的目标文本(每句):"), text)
|
| 434 |
phones2, word2ph2, norm_text2 = get_cleaned_text_final(text, text_language)
|
| 435 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 436 |
bert = torch.cat([bert1, bert2], 1)
|
| 437 |
|
| 438 |
all_phoneme_ids = torch.LongTensor(phones1 + phones2).to(device).unsqueeze(0)
|
|
@@ -686,7 +690,7 @@ def clone_voice(user_voice,user_text,user_lang):
|
|
| 686 |
if user_text == '':
|
| 687 |
wprint("Please enter text to generate/请输入生成文字")
|
| 688 |
return None
|
| 689 |
-
|
| 690 |
user_text=trim_text(user_text,user_lang)
|
| 691 |
time1=timer()
|
| 692 |
global gpt_path, sovits_path
|
|
@@ -724,18 +728,22 @@ with gr.Blocks(theme='Kasien/ali_theme_custom') as app:
|
|
| 724 |
gr.HTML('''
|
| 725 |
<h1 style="font-size: 25px;">A TTS GENERATOR</h1>
|
| 726 |
<p style="margin-bottom: 10px; font-size: 100%">
|
| 727 |
-
|
| 728 |
-
|
| 729 |
-
|
|
|
|
| 730 |
You can visit the repo's github homepage to learn training and inference.<br>
|
| 731 |
-
|
| 732 |
-
|
| 733 |
-
|
| 734 |
-
|
| 735 |
-
由于本空间使用huggingface的免费CPU
|
| 736 |
-
|
| 737 |
-
|
| 738 |
-
|
|
|
|
|
|
|
|
|
|
| 739 |
''')
|
| 740 |
|
| 741 |
default_voice_wav, default_voice_wav_words, default_language, _, default_model_name, _, default_tone_sample_path = update_model("Trump")
|
|
@@ -749,7 +757,9 @@ with gr.Blocks(theme='Kasien/ali_theme_custom') as app:
|
|
| 749 |
|
| 750 |
plsh='Text must match the selected language option to prevent errors, for example, if English is input but Chinese is selected for generation.\n文字一定要和语言选项匹配,不然要报错,比如输入的是英文,生成语言选中文'
|
| 751 |
limit='Max 70 words. Excess will be ignored./单次最多处理120字左���,多余的会被忽略'
|
| 752 |
-
|
|
|
|
|
|
|
| 753 |
with gr.Row():
|
| 754 |
model_name = gr.Textbox(label="Seleted Model/已选模型", value=default_model_name, scale=1)
|
| 755 |
text = gr.Textbox(label="Input some text for voice generation/输入想要生成语音的文字", lines=5,scale=8,
|
|
@@ -794,7 +804,8 @@ with gr.Blocks(theme='Kasien/ali_theme_custom') as app:
|
|
| 794 |
volume = gr.Slider(minimum=0.5, maximum=2, value=1, step=0.01, label='Volume/音量')
|
| 795 |
|
| 796 |
|
| 797 |
-
|
|
|
|
| 798 |
with gr.Row():
|
| 799 |
main_button = gr.Button("✨Generate Voice", variant="primary", scale=1)
|
| 800 |
output = gr.Audio(label="💾Download it by clicking ⬇️", scale=3)
|
|
|
|
| 432 |
if (text[-1] not in splits): text += "。" if text_language != "en" else "."
|
| 433 |
print(("\n🎈实际输入的目标文本(每句):"), text)
|
| 434 |
phones2, word2ph2, norm_text2 = get_cleaned_text_final(text, text_language)
|
| 435 |
+
try:
|
| 436 |
+
bert2 = get_bert_final(phones2, word2ph2, norm_text2, text_language, device).to(dtype)
|
| 437 |
+
except RuntimeError as e:
|
| 438 |
+
wprint(f"The input text does not match the language/输入文本与语言不匹配: {e}")
|
| 439 |
+
return None
|
| 440 |
bert = torch.cat([bert1, bert2], 1)
|
| 441 |
|
| 442 |
all_phoneme_ids = torch.LongTensor(phones1 + phones2).to(device).unsqueeze(0)
|
|
|
|
| 690 |
if user_text == '':
|
| 691 |
wprint("Please enter text to generate/请输入生成文字")
|
| 692 |
return None
|
| 693 |
+
tprint('⚡Start clone')
|
| 694 |
user_text=trim_text(user_text,user_lang)
|
| 695 |
time1=timer()
|
| 696 |
global gpt_path, sovits_path
|
|
|
|
| 728 |
gr.HTML('''
|
| 729 |
<h1 style="font-size: 25px;">A TTS GENERATOR</h1>
|
| 730 |
<p style="margin-bottom: 10px; font-size: 100%">
|
| 731 |
+
If you like this space, please click the ❤️ at the top of the page..如喜欢,请点一下页面顶部的❤️<br>
|
| 732 |
+
</p>''')
|
| 733 |
+
|
| 734 |
+
gr.Markdown("""* This space is based on the text-to-speech generation solution GPT-SoVITS .
|
| 735 |
You can visit the repo's github homepage to learn training and inference.<br>
|
| 736 |
+
本空间基于文字转语音生成方案 GPT-SoVITS . 你可以前往项目的github主页学习如何推理和训练。
|
| 737 |
+
* ⚠️Generating voice is very slow due to using HuggingFace's free CPU in this space.
|
| 738 |
+
For faster generation, click the Colab icon below to use this space in Colab,
|
| 739 |
+
which will significantly improve the speed.<br>
|
| 740 |
+
由于本空间使用huggingface的免费CPU进行推理,因此速度很慢,如想快速生成,请点击下方的Colab图标,
|
| 741 |
+
前往Colab使用已获得更快的生成速度。
|
| 742 |
+
<br>Colabの使用を強くお勧めします。より速い生成速度が得られます。
|
| 743 |
+
* The model's corresponding language is its native language, but in fact,
|
| 744 |
+
each model can speak three languages.<br>模型对应的语言是其母语,但实际上,
|
| 745 |
+
每个模型都能说三种语言<br>モデルに対応する言語はその母国語ですが、実際には、各モデルは3つの言語を話すことができます。""")
|
| 746 |
+
gr.HTML('''<a href="https://colab.research.google.com/drive/1fTuPZ4tZsAjS-TrhQWMCb7KRdnU8aF6j#scrollTo=MDtJIbLdLHe9" target="_blank"><img src="https://camo.githubusercontent.com/dd83d4a334eab7ada034c13747d9e2237182826d32e3fda6629740b6e02f18d8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f6c61622d4639414230303f7374796c653d666f722d7468652d6261646765266c6f676f3d676f6f676c65636f6c616226636f6c6f723d353235323532" alt="colab"></a>
|
| 747 |
''')
|
| 748 |
|
| 749 |
default_voice_wav, default_voice_wav_words, default_language, _, default_model_name, _, default_tone_sample_path = update_model("Trump")
|
|
|
|
| 757 |
|
| 758 |
plsh='Text must match the selected language option to prevent errors, for example, if English is input but Chinese is selected for generation.\n文字一定要和语言选项匹配,不然要报错,比如输入的是英文,生成语言选中文'
|
| 759 |
limit='Max 70 words. Excess will be ignored./单次最多处理120字左���,多余的会被忽略'
|
| 760 |
+
|
| 761 |
+
gr.HTML('''
|
| 762 |
+
<b>输入文字</b>''')
|
| 763 |
with gr.Row():
|
| 764 |
model_name = gr.Textbox(label="Seleted Model/已选模型", value=default_model_name, scale=1)
|
| 765 |
text = gr.Textbox(label="Input some text for voice generation/输入想要生成语音的文字", lines=5,scale=8,
|
|
|
|
| 804 |
volume = gr.Slider(minimum=0.5, maximum=2, value=1, step=0.01, label='Volume/音量')
|
| 805 |
|
| 806 |
|
| 807 |
+
gr.HTML('''
|
| 808 |
+
<b>开始生成</b>''')
|
| 809 |
with gr.Row():
|
| 810 |
main_button = gr.Button("✨Generate Voice", variant="primary", scale=1)
|
| 811 |
output = gr.Audio(label="💾Download it by clicking ⬇️", scale=3)
|