{"record":{"id":"79e806bb6574af1b","repo":"RVC-Boss/GPT-SoVITS","slug":"error-79e806","errorCode":null,"errorMessage":"请输入有效文本","messagePattern":"请输入有效文本","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"GPT_SoVITS/inference_webui.py","lineNumber":1183,"sourceCode":"    if items:\r\n        mergeitems.append(\"\".join(items))\r\n\r\n    opt = [item for item in mergeitems if not set(item).issubset(punds)]\r\n    return \"\\n\".join(opt)\r\n\r\n\r\ndef custom_sort_key(s):\r\n    # 使用正则表达式提取字符串中的数字部分和非数字部分\r\n    parts = re.split(\"(\\d+)\", s)\r\n    # 将数字部分转换为整数，非数字部分保持不变\r\n    parts = [int(part) if part.isdigit() else part for part in parts]\r\n    return parts\r\n\r\n\r\ndef process_text(texts):\r\n    _text = []\r\n    if all(text in [None, \" \", \"\\n\", \"\"] for text in texts):\r\n        raise ValueError(i18n(\"请输入有效文本\"))\r\n    for text in texts:\r\n        if text in [None, \" \", \"\"]:\r\n            pass\r\n        else:\r\n            _text.append(text)\r\n    return _text\r\n\r\n\r\ndef html_center(text, label=\"p\"):\r\n    return f\"\"\"<div style=\"text-align: center; margin: 100; padding: 50;\">\r\n                <{label} style=\"margin: 0; padding: 0;\">{text}</{label}>\r\n                </div>\"\"\"\r\n\r\n\r\ndef html_left(text, label=\"p\"):\r\n    return f\"\"\"<div style=\"text-align: left; margin: 0; padding: 0;\">\r\n                <{label} style=\"margin: 0; padding: 0;\">{text}</{label}>\r\n                </div>\"\"\"\r","sourceCodeStart":1165,"sourceCodeEnd":1201,"githubUrl":"https://github.com/RVC-Boss/GPT-SoVITS/blob/d523079fc05d9a8028d6085bffe4a2757c32abb6/GPT_SoVITS/inference_webui.py#L1165-L1201","documentation":"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\").","triggerScenarios":"Clicking 开始转换/Generate in the Gradio webui with an empty textbox, a whitespace-only textbox, or text that the splitter reduces to only blank fragments.","commonSituations":"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.","solutions":["Type or paste actual text to synthesize and retry.","Disable the generate button client-side until the textbox is non-blank.","In scripted use, skip the call when not text.strip().","For server integrations, validate payload text and return a 400 with a friendly message."],"exampleFix":"# before\nresult = translate_tts_params(...) with text=\" \"  # ValueError: 请输入有效文本\n\n# after\nif not (text or \"\").strip():\n    gr.Warning(\"请输入有效文本\")\n    return\nresult = process_text([text])","handlingStrategy":"validation","validationCode":"if not any((t or \"\").strip() for t in texts):\n    gr.Warning(\"请输入有效文本\")\n    return","typeGuard":"def has_synthable_text(texts: list[str | None]) -> bool:\n    return any(t is not None and t.strip() for t in texts)","tryCatchPattern":null,"preventionTips":["Guard generate handlers with a blank-text check before calling process_text.","Keep UI text state synchronized across model switches.","In automation, skip empty rows rather than passing them through."],"tags":["text-validation","empty-input","webui","preprocessing"],"backgroundTag":null,"analyzedSha":"d523079fc05d9a8028d6085bffe4a2757c32abb6","analyzedAt":"2026-08-15T01:06:46.402Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}