RVC-Boss/GPT-SoVITS · error · ValueError

请输入有效文本

Error message

请输入有效文本

What it means

Webui copy of TextPreprocessor.filter_text: process_text() raises ValueError when every string in the batch is blank (None, " ", "\n", ""). It runs during the cut_text/process_text stage before synthesis; if text cutting produced only empty fragments there is nothing to send to the models, so it aborts with 请输入有效文本 ("please input valid text").

Solutions

  1. Type or paste actual text to synthesize and retry.
  2. Disable the generate button client-side until the textbox is non-blank.
  3. In scripted use, skip the call when not text.strip().
  4. For server integrations, validate payload text and return a 400 with a friendly message.

Example fix

# before
result = translate_tts_params(...) with text=" "  # ValueError: 请输入有效文本

# after
if not (text or "").strip():
    gr.Warning("请输入有效文本")
    return
result = process_text([text])
Defensive patterns

Strategy: validation

Validate before calling

if not any((t or "").strip() for t in texts):
    gr.Warning("请输入有效文本")
    return

Type guard

def has_synthable_text(texts: list[str | None]) -> bool:
    return any(t is not None and t.strip() for t in texts)

Prevention

When it happens

Trigger: Clicking 开始转换/Generate in the Gradio webui with an empty textbox, a whitespace-only textbox, or text that the splitter reduces to only blank fragments.

Common situations: Generate clicked before typing anything; frontend state reset after model switch leaving empty text; text composed solely of characters the cleaner strips; automation/script driving the webui function with empty strings.

Related errors


AI-assisted analysis of RVC-Boss/GPT-SoVITS@d523079fc0 (2026-08-15). Data as JSON: /api/errors/79e806bb6574af1b. Report an issue: GitHub.

Appendix: source

Thrown at GPT_SoVITS/inference_webui.py:1183

    if items:
        mergeitems.append("".join(items))

    opt = [item for item in mergeitems if not set(item).issubset(punds)]
    return "\n".join(opt)


def custom_sort_key(s):
    # 使用正则表达式提取字符串中的数字部分和非数字部分
    parts = re.split("(\d+)", s)
    # 将数字部分转换为整数,非数字部分保持不变
    parts = [int(part) if part.isdigit() else part for part in parts]
    return parts


def process_text(texts):
    _text = []
    if all(text in [None, " ", "\n", ""] for text in texts):
        raise ValueError(i18n("请输入有效文本"))
    for text in texts:
        if text in [None, " ", ""]:
            pass
        else:
            _text.append(text)
    return _text


def html_center(text, label="p"):
    return f"""<div style="text-align: center; margin: 100; padding: 50;">
                <{label} style="margin: 0; padding: 0;">{text}</{label}>
                </div>"""


def html_left(text, label="p"):
    return f"""<div style="text-align: left; margin: 0; padding: 0;">
                <{label} style="margin: 0; padding: 0;">{text}</{label}>
                </div>"""

View on GitHub (pinned to d523079fc0)