From b7153dcae74ee2cd9aec1f8cb1e13bfbab3e7aba Mon Sep 17 00:00:00 2001 From: XucroYuri Date: Tue, 7 Jul 2026 13:28:29 +0800 Subject: [PATCH] =?UTF-8?q?refactor(webui):=20=E6=97=A0=E5=8F=82=E8=80=83?= =?UTF-8?q?=E6=96=87=E6=9C=AC=E5=8B=BE=E9=80=89=E6=95=B4=E5=90=88=E5=88=B0?= =?UTF-8?q?=E8=AE=AD=E7=BB=83=E6=A0=B7=E6=9C=AC=E5=8C=BA,=20v3/v4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=B1=82=E9=9A=90=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 按功能逻辑重组: ref_text_free 与训练样本下拉功能局部互斥 (勾选后参考音频生效但参考文本无效), 故同区呈现。 1. ref_text_free checkbox 从参考文本列移到训练样本下拉同行: [训练样本音频(scale20) | 无参考文本模式勾选(scale8)] = 28 对齐 2. 文案精简: - 旧: '开启无参考文本模式。不填参考文本亦相当于开启。v3暂不支持该模式,使用了会报错。' - 新: '无参考文本模式(勾选后忽略参考文本,仅用参考音频音色)' - 删除冗长说明 markdown ('使用无参考文本模式时建议...' '听不清参考音频...') 3. v3/v4 代码层安全屏蔽 (减少用户误操作): - 初始 visible=model_version not in v3v4set (v3/v4 直接隐藏) - change_sovits_weights 切换权重时同步更新 visible (2处) - 原'使用了会报错'的文案预警改为直接隐藏, 不给用户犯错机会 验证: v2ProPlus下勾选框可见可用; 端到端切样本->参考音频+文本+情绪正常。 --- GPT_SoVITS/inference_webui.py | 45 ++++++++++++++++------------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/GPT_SoVITS/inference_webui.py b/GPT_SoVITS/inference_webui.py index 511c39a7..ae1c897a 100644 --- a/GPT_SoVITS/inference_webui.py +++ b/GPT_SoVITS/inference_webui.py @@ -309,7 +309,7 @@ def change_sovits_weights(sovits_path, prompt_language=None, text_language=None) "choices": [4, 8, 16, 32, 64, 128] if model_version == "v3" else [4, 8, 16, 32], }, {"__type__": "update", "visible": visible_inp_refs}, - {"__type__": "update", "value": False, "interactive": True if model_version not in v3v4set else False}, + {"__type__": "update", "value": False, "interactive": True if model_version not in v3v4set else False, "visible": model_version not in v3v4set}, {"__type__": "update", "visible": True if model_version == "v3" else False}, {"__type__": "update", "value": i18n("模型加载中,请等待"), "interactive": False}, ) @@ -391,7 +391,7 @@ def change_sovits_weights(sovits_path, prompt_language=None, text_language=None) "choices": [4, 8, 16, 32, 64, 128] if model_version == "v3" else [4, 8, 16, 32], }, {"__type__": "update", "visible": visible_inp_refs}, - {"__type__": "update", "value": False, "interactive": True if model_version not in v3v4set else False}, + {"__type__": "update", "value": False, "interactive": True if model_version not in v3v4set else False, "visible": model_version not in v3v4set}, {"__type__": "update", "visible": True if model_version == "v3" else False}, {"__type__": "update", "value": i18n("合成语音"), "interactive": True}, ) @@ -1475,31 +1475,28 @@ with gr.Blocks(title="GPT-SoVITS WebUI", analytics_enabled=False, js=js, css=css refresh_button.click(fn=change_choices, inputs=[], outputs=[SoVITS_dropdown, GPT_dropdown]) with gr.Group(): gr.Markdown(html_center(i18n("*请上传并填写参考信息"), "h3")) - # 训练样本下拉: 入口与输出聚合 — 选中即自动引用为参考音频+文本+情绪 - ref_sample_dropdown = gr.Dropdown( - label=i18n("训练样本音频(选中即自动引用为参考音频)"), - choices=[], - value="", - interactive=True, - ) + # 训练样本下拉 + 无参考文本开关: 入口与输出聚合 + # ref_text_free 与样本下拉功能局部互斥(勾选后参考文本无效), 故同区呈现 + with gr.Row(): + ref_sample_dropdown = gr.Dropdown( + label=i18n("训练样本音频(选中即自动引用为参考音频)"), + choices=[], + value="", + interactive=True, + scale=20, + ) + ref_text_free = gr.Checkbox( + label=i18n("无参考文本模式(勾选后忽略参考文本,仅用参考音频音色)"), + value=False, + interactive=True if model_version not in v3v4set else False, + show_label=True, + scale=8, + # v3/v4 不支持该模式: 代码层直接隐藏, 避免用户误操作报错 + visible=model_version not in v3v4set, + ) with gr.Row(): inp_ref = gr.Audio(label=i18n("请上传参考音频(推荐3~10秒)"), type="filepath", scale=13) with gr.Column(scale=13): - ref_text_free = gr.Checkbox( - label=i18n("开启无参考文本模式。不填参考文本亦相当于开启。") - + i18n("v3暂不支持该模式,使用了会报错。"), - value=False, - interactive=True if model_version not in v3v4set else False, - show_label=True, - scale=1, - ) - gr.Markdown( - html_left( - i18n("使用无参考文本模式时建议使用微调的GPT") - + "
" - + i18n("听不清参考音频说的啥(不晓得写啥)可以开。开启后无视填写的参考文本。") - ) - ) prompt_text = gr.Textbox(label=i18n("参考音频的文本"), value="", lines=5, max_lines=5, scale=1) ref_emotion_text = gr.Textbox( label=i18n("情绪/括注(来自训练样本,无数据留空)"),