Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
@@ -16,10 +16,6 @@ logging.basicConfig(
|
|
16 |
logger = logging.getLogger(__name__)
|
17 |
|
18 |
import torch
|
19 |
-
import ssl
|
20 |
-
ssl._create_default_https_context = ssl._create_unverified_context
|
21 |
-
import nltk
|
22 |
-
nltk.download('cmudict')
|
23 |
import utils
|
24 |
from infer import infer, latest_version, get_net_g, infer_multilang
|
25 |
import gradio as gr
|
@@ -390,26 +386,20 @@ if __name__ == "__main__":
|
|
390 |
with gr.Blocks() as app:
|
391 |
with gr.Row():
|
392 |
with gr.Column():
|
393 |
-
gr.Markdown(value="""
|
394 |
-
【AI阿梓】在线语音合成(Bert-Vits2 2.3中日英)\n
|
395 |
-
作者:Xz乔希 https://space.bilibili.com/5859321\n
|
396 |
-
声音归属:阿梓从小就很可爱 https://space.bilibili.com/7706705\n
|
397 |
-
【AI合集】https://www.modelscope.cn/studios/xzjosh/Bert-VITS2\n
|
398 |
-
Bert-VITS2项目:https://github.com/Stardust-minus/Bert-VITS2\n
|
399 |
-
使用本模型请严格遵守法律法规!\n
|
400 |
-
发布二创作品请标注本项目作者及链接、作品使用Bert-VITS2 AI生成!\n
|
401 |
-
【提示】手机端容易误触调节,请刷新恢复默认!每次生成的结果都不一样,效果不好请尝试多次生成与调节,选择最佳结果!\n
|
402 |
-
""")
|
403 |
text = gr.TextArea(
|
404 |
label="输入文本内容",
|
405 |
placeholder="""
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
|
|
|
|
411 |
""",
|
412 |
)
|
|
|
|
|
413 |
formatter = gr.Button("检测语言,并整理为 MIX 格式", variant="primary")
|
414 |
speaker = gr.Dropdown(
|
415 |
choices=speakers, value=speakers[0], label="Speaker"
|
@@ -434,26 +424,26 @@ if __name__ == "__main__":
|
|
434 |
label="Audio prompt", type="filepath", visible=False
|
435 |
)
|
436 |
sdp_ratio = gr.Slider(
|
437 |
-
minimum=0, maximum=1, value=0.5, step=0.
|
438 |
)
|
439 |
noise_scale = gr.Slider(
|
440 |
-
minimum=0.1, maximum=2, value=0.
|
441 |
)
|
442 |
noise_scale_w = gr.Slider(
|
443 |
-
minimum=0.1, maximum=2, value=0.9, step=0.
|
444 |
)
|
445 |
length_scale = gr.Slider(
|
446 |
-
minimum=0.1, maximum=2, value=1.0, step=0.
|
447 |
)
|
448 |
language = gr.Dropdown(
|
449 |
choices=languages, value=languages[0], label="Language"
|
450 |
)
|
451 |
-
btn = gr.Button("
|
452 |
with gr.Column():
|
453 |
-
with gr.Accordion("
|
454 |
gr.Markdown(
|
455 |
value="使用辅助文本的语意来辅助生成对话(语言保持与主文本相同)\n\n"
|
456 |
-
"
|
457 |
"效果较不明确,留空即为不使用该功能"
|
458 |
)
|
459 |
style_text = gr.Textbox(label="辅助文本")
|
@@ -512,6 +502,12 @@ if __name__ == "__main__":
|
|
512 |
],
|
513 |
outputs=[text_output, audio_output],
|
514 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
515 |
slicer.click(
|
516 |
tts_split,
|
517 |
inputs=[
|
@@ -545,6 +541,12 @@ if __name__ == "__main__":
|
|
545 |
outputs=[audio_prompt],
|
546 |
)
|
547 |
|
|
|
|
|
|
|
|
|
|
|
|
|
548 |
print("推理页面已开启!")
|
549 |
webbrowser.open(f"http://127.0.0.1:{config.webui_config.port}")
|
550 |
app.launch(share=config.webui_config.share, server_port=config.webui_config.port)
|
|
|
16 |
logger = logging.getLogger(__name__)
|
17 |
|
18 |
import torch
|
|
|
|
|
|
|
|
|
19 |
import utils
|
20 |
from infer import infer, latest_version, get_net_g, infer_multilang
|
21 |
import gradio as gr
|
|
|
386 |
with gr.Blocks() as app:
|
387 |
with gr.Row():
|
388 |
with gr.Column():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
389 |
text = gr.TextArea(
|
390 |
label="输入文本内容",
|
391 |
placeholder="""
|
392 |
+
如果你选择语言为\'mix\',必须按照格式输入,否则报错:
|
393 |
+
格式举例(zh是中文,jp是日语,不区分大小写;说话人举例:gongzi):
|
394 |
+
[说话人1]<zh>你好,こんにちは! <jp>こんにちは,世界。
|
395 |
+
[说话人2]<zh>你好吗?<jp>元気ですか?
|
396 |
+
[说话人3]<zh>谢谢。<jp>どういたしまして。
|
397 |
+
...
|
398 |
+
另外,所有的语言选项都可以用'|'分割长段实现分句生成。
|
399 |
""",
|
400 |
)
|
401 |
+
trans = gr.Button("中翻日", variant="primary")
|
402 |
+
slicer = gr.Button("快速切分", variant="primary")
|
403 |
formatter = gr.Button("检测语言,并整理为 MIX 格式", variant="primary")
|
404 |
speaker = gr.Dropdown(
|
405 |
choices=speakers, value=speakers[0], label="Speaker"
|
|
|
424 |
label="Audio prompt", type="filepath", visible=False
|
425 |
)
|
426 |
sdp_ratio = gr.Slider(
|
427 |
+
minimum=0, maximum=1, value=0.5, step=0.1, label="SDP Ratio"
|
428 |
)
|
429 |
noise_scale = gr.Slider(
|
430 |
+
minimum=0.1, maximum=2, value=0.6, step=0.1, label="Noise"
|
431 |
)
|
432 |
noise_scale_w = gr.Slider(
|
433 |
+
minimum=0.1, maximum=2, value=0.9, step=0.1, label="Noise_W"
|
434 |
)
|
435 |
length_scale = gr.Slider(
|
436 |
+
minimum=0.1, maximum=2, value=1.0, step=0.1, label="Length"
|
437 |
)
|
438 |
language = gr.Dropdown(
|
439 |
choices=languages, value=languages[0], label="Language"
|
440 |
)
|
441 |
+
btn = gr.Button("生成音频!", variant="primary")
|
442 |
with gr.Column():
|
443 |
+
with gr.Accordion("融合文本语义", open=False):
|
444 |
gr.Markdown(
|
445 |
value="使用辅助文本的语意来辅助生成对话(语言保持与主文本相同)\n\n"
|
446 |
+
"**注意**:不要使用**指令式文本**(如:开心),要使用**带有强烈情感的文本**(如:我好快乐!!!)\n\n"
|
447 |
"效果较不明确,留空即为不使用该功能"
|
448 |
)
|
449 |
style_text = gr.Textbox(label="辅助文本")
|
|
|
502 |
],
|
503 |
outputs=[text_output, audio_output],
|
504 |
)
|
505 |
+
|
506 |
+
trans.click(
|
507 |
+
translate,
|
508 |
+
inputs=[text],
|
509 |
+
outputs=[text],
|
510 |
+
)
|
511 |
slicer.click(
|
512 |
tts_split,
|
513 |
inputs=[
|
|
|
541 |
outputs=[audio_prompt],
|
542 |
)
|
543 |
|
544 |
+
formatter.click(
|
545 |
+
format_utils,
|
546 |
+
inputs=[text, speaker],
|
547 |
+
outputs=[language, text],
|
548 |
+
)
|
549 |
+
|
550 |
print("推理页面已开启!")
|
551 |
webbrowser.open(f"http://127.0.0.1:{config.webui_config.port}")
|
552 |
app.launch(share=config.webui_config.share, server_port=config.webui_config.port)
|