Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -650,6 +650,9 @@ def trim_text(text,language):
|
|
650 |
return text[:limit_cj]
|
651 |
|
652 |
def duration(audio_file_path):
|
|
|
|
|
|
|
653 |
try:
|
654 |
audio_duration = librosa.get_duration(filename=audio_file_path)
|
655 |
if not 3 < audio_duration < 10:
|
@@ -657,7 +660,6 @@ def duration(audio_file_path):
|
|
657 |
return False
|
658 |
return True
|
659 |
except FileNotFoundError:
|
660 |
-
wprint("Failed to obtain uploaded audio/未找到音频文件")
|
661 |
return False
|
662 |
|
663 |
def update_model(choice):
|
@@ -723,7 +725,12 @@ def clone_voice(user_voice,user_text,user_lang):
|
|
723 |
#tprint(f'Model loaded:{gpt_path}')
|
724 |
sovits_path = abs_path("pretrained_models/s2G488k.pth")
|
725 |
#tprint(f'Model loaded:{sovits_path}')
|
726 |
-
|
|
|
|
|
|
|
|
|
|
|
727 |
output_wav = get_tts_wav(
|
728 |
user_voice,
|
729 |
prompt_text,
|
@@ -751,23 +758,22 @@ for model_name, model_info in models.items():
|
|
751 |
|
752 |
with gr.Blocks(theme='Kasien/ali_theme_custom') as app:
|
753 |
gr.HTML('''
|
754 |
-
<h1 style="font-size: 25px;">
|
|
|
755 |
<p style="margin-bottom: 10px; font-size: 100%">
|
756 |
If you like this space, please click the ❤️ at the top of the page..如喜欢,请点一下页面顶部的❤️<br>
|
757 |
</p>''')
|
758 |
|
759 |
gr.Markdown("""* This space is based on the text-to-speech generation solution [GPT-SoVITS](https://github.com/RVC-Boss/GPT-SoVITS) .
|
760 |
You can visit the repo's github homepage to learn training and inference.<br>
|
761 |
-
本空间基于文字转语音生成方案[GPT-SoVITS](https://github.com/RVC-Boss/GPT-SoVITS)
|
762 |
* ⚠️Generating voice is very slow due to using HuggingFace's free CPU in this space.
|
763 |
For faster generation, click the Colab icon below to use this space in Colab,
|
764 |
which will significantly improve the speed.<br>
|
765 |
由于本空间使用huggingface的免费CPU进行推理,因此速度很慢,如想快速生成,请点击下方的Colab图标,
|
766 |
前往Colab使用已获得更快的生成速度。
|
767 |
<br>Colabの使用を強くお勧めします。より速い生成速度が得られます。
|
768 |
-
*
|
769 |
-
each model can speak three languages.<br>模型对应的语言是其母语,但实际上,
|
770 |
-
每个模型都能说三种语言<br>モデルに対応する言語はその母国語ですが、実際には、各モデルは3つの言語を話すことができます。""")
|
771 |
gr.HTML('''<a href="https://colab.research.google.com/drive/1fTuPZ4tZsAjS-TrhQWMCb7KRdnU8aF6j" target="_blank"><img src="https://camo.githubusercontent.com/dd83d4a334eab7ada034c13747d9e2237182826d32e3fda6629740b6e02f18d8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f6c61622d4639414230303f7374796c653d666f722d7468652d6261646765266c6f676f3d676f6f676c65636f6c616226636f6c6f723d353235323532" alt="colab"></a>
|
772 |
''')
|
773 |
|
@@ -776,11 +782,11 @@ with gr.Blocks(theme='Kasien/ali_theme_custom') as app:
|
|
776 |
chinese_models = [name for name, _ in models_by_language["中文"]]
|
777 |
japanese_models = [name for name, _ in models_by_language["日本語"]]
|
778 |
with gr.Row():
|
779 |
-
english_choice = gr.Radio(english_models, label="
|
780 |
-
chinese_choice = gr.Radio(chinese_models, label="
|
781 |
-
japanese_choice = gr.Radio(japanese_models, label="
|
782 |
|
783 |
-
plsh='Input
|
784 |
limit='Max 70 words. Excess will be ignored./单次最多处理120字左右,多余的会被忽略'
|
785 |
|
786 |
gr.HTML('''
|
@@ -789,10 +795,10 @@ with gr.Blocks(theme='Kasien/ali_theme_custom') as app:
|
|
789 |
with gr.Column(scale=2):
|
790 |
model_name = gr.Textbox(label="Seleted Model/已选模型", value=default_model_name, scale=1)
|
791 |
text_language = gr.Textbox(
|
792 |
-
label="
|
793 |
info='Automatic detection of input language type.',scale=1,interactive=False
|
794 |
)
|
795 |
-
text = gr.Textbox(label="
|
796 |
placeholder=plsh,info=limit)
|
797 |
text.change( lang_detector, text, text_language)
|
798 |
|
|
|
650 |
return text[:limit_cj]
|
651 |
|
652 |
def duration(audio_file_path):
|
653 |
+
if not audio_file_path:
|
654 |
+
wprint("Failed to obtain uploaded audio/未找到音频文件")
|
655 |
+
return False
|
656 |
try:
|
657 |
audio_duration = librosa.get_duration(filename=audio_file_path)
|
658 |
if not 3 < audio_duration < 10:
|
|
|
660 |
return False
|
661 |
return True
|
662 |
except FileNotFoundError:
|
|
|
663 |
return False
|
664 |
|
665 |
def update_model(choice):
|
|
|
725 |
#tprint(f'Model loaded:{gpt_path}')
|
726 |
sovits_path = abs_path("pretrained_models/s2G488k.pth")
|
727 |
#tprint(f'Model loaded:{sovits_path}')
|
728 |
+
try:
|
729 |
+
prompt_text, prompt_lang = transcribe(user_voice)
|
730 |
+
except UnboundLocalError as e:
|
731 |
+
wprint(f"The language in the audio cannot be recognized :{str(e)}")
|
732 |
+
return None
|
733 |
+
|
734 |
output_wav = get_tts_wav(
|
735 |
user_voice,
|
736 |
prompt_text,
|
|
|
758 |
|
759 |
with gr.Blocks(theme='Kasien/ali_theme_custom') as app:
|
760 |
gr.HTML('''
|
761 |
+
<h1 style="font-size: 25px;">TEXT TO SPEECH</h1>
|
762 |
+
<h1 style="font-size: 20px;">Support English/Chinese/Japanese</h1>
|
763 |
<p style="margin-bottom: 10px; font-size: 100%">
|
764 |
If you like this space, please click the ❤️ at the top of the page..如喜欢,请点一下页面顶部的❤️<br>
|
765 |
</p>''')
|
766 |
|
767 |
gr.Markdown("""* This space is based on the text-to-speech generation solution [GPT-SoVITS](https://github.com/RVC-Boss/GPT-SoVITS) .
|
768 |
You can visit the repo's github homepage to learn training and inference.<br>
|
769 |
+
本空间基于文字转语音生成方案 [GPT-SoVITS](https://github.com/RVC-Boss/GPT-SoVITS). 你可以前往项目的github主页学习如何推理和训练。
|
770 |
* ⚠️Generating voice is very slow due to using HuggingFace's free CPU in this space.
|
771 |
For faster generation, click the Colab icon below to use this space in Colab,
|
772 |
which will significantly improve the speed.<br>
|
773 |
由于本空间使用huggingface的免费CPU进行推理,因此速度很慢,如想快速生成,请点击下方的Colab图标,
|
774 |
前往Colab使用已获得更快的生成速度。
|
775 |
<br>Colabの使用を強くお勧めします。より速い生成速度が得られます。
|
776 |
+
* each model can speak three languages.<br>每个模型都能说三种语言<br>各モデルは3つの言語を話すことができます。""")
|
|
|
|
|
777 |
gr.HTML('''<a href="https://colab.research.google.com/drive/1fTuPZ4tZsAjS-TrhQWMCb7KRdnU8aF6j" target="_blank"><img src="https://camo.githubusercontent.com/dd83d4a334eab7ada034c13747d9e2237182826d32e3fda6629740b6e02f18d8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f6c61622d4639414230303f7374796c653d666f722d7468652d6261646765266c6f676f3d676f6f676c65636f6c616226636f6c6f723d353235323532" alt="colab"></a>
|
778 |
''')
|
779 |
|
|
|
782 |
chinese_models = [name for name, _ in models_by_language["中文"]]
|
783 |
japanese_models = [name for name, _ in models_by_language["日本語"]]
|
784 |
with gr.Row():
|
785 |
+
english_choice = gr.Radio(english_models, label="1",value="Trump",scale=3)
|
786 |
+
chinese_choice = gr.Radio(chinese_models, label="2",scale=2)
|
787 |
+
japanese_choice = gr.Radio(japanese_models, label="3",scale=4)
|
788 |
|
789 |
+
plsh='Support【English/中文/日本語】,Input text you like / 輸入文字 /テキストを入力する'
|
790 |
limit='Max 70 words. Excess will be ignored./单次最多处理120字左右,多余的会被忽略'
|
791 |
|
792 |
gr.HTML('''
|
|
|
795 |
with gr.Column(scale=2):
|
796 |
model_name = gr.Textbox(label="Seleted Model/已选模型", value=default_model_name, scale=1)
|
797 |
text_language = gr.Textbox(
|
798 |
+
label="Language for input text/生成语言",
|
799 |
info='Automatic detection of input language type.',scale=1,interactive=False
|
800 |
)
|
801 |
+
text = gr.Textbox(label="INPUT TEXT", lines=5,scale=6,
|
802 |
placeholder=plsh,info=limit)
|
803 |
text.change( lang_detector, text, text_language)
|
804 |
|