{"record":{"id":"3898fa8cfb89c6ca","repo":"RVC-Boss/GPT-SoVITS","slug":"error","errorCode":null,"errorMessage":"请输入有效文本","messagePattern":"请输入有效文本","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"GPT_SoVITS/TTS_infer_pack/TextPreprocessor.py","lineNumber":227,"sourceCode":"        phones = cleaned_text_to_sequence(phones, version)\n        return phones, word2ph, norm_text\n\n    def get_bert_inf(self, phones: list, word2ph: list, norm_text: str, language: str):\n        language = language.replace(\"all_\", \"\")\n        if language == \"zh\":\n            feature = self.get_bert_feature(norm_text, word2ph).to(self.device)\n        else:\n            feature = torch.zeros(\n                (1024, len(phones)),\n                dtype=torch.float32,\n            ).to(self.device)\n\n        return feature\n\n    def filter_text(self, texts):\n        _text = []\n        if all(text in [None, \" \", \"\\n\", \"\"] for text in texts):\n            raise ValueError(i18n(\"请输入有效文本\"))\n        for text in texts:\n            if text in [None, \" \", \"\"]:\n                pass\n            else:\n                _text.append(text)\n        return _text\n\n    def replace_consecutive_punctuation(self, text):\n        punctuations = \"\".join(re.escape(p) for p in punctuation)\n        pattern = f\"([{punctuations}])([{punctuations}])+\"\n        result = re.sub(pattern, r\"\\1\", text)\n        return result","sourceCodeStart":209,"sourceCodeEnd":239,"githubUrl":"https://github.com/RVC-Boss/GPT-SoVITS/blob/d523079fc05d9a8028d6085bffe4a2757c32abb6/GPT_SoVITS/TTS_infer_pack/TextPreprocessor.py#L209-L239","documentation":"ValueError raised by TextPreprocessor.filter_text() when every entry in the input list of texts is empty-ish (None, \"\", \" \", \"\\n\"). Text segmentation/splitting eventually calls filter_text before any model runs; with no non-blank segments left there is literally nothing to synthesize, so it fails fast rather than running the models on empty input.","triggerScenarios":"Calling infer_batch/run (which routes text through TextPreprocessor) with text=None, \"\", \" \", \"\\n\", or text that segments entirely into blank pieces (e.g. a string of only newlines/spaces).","commonSituations":"Frontend sends an empty textbox value; UI text field was never filled but the generate button clicked; upstream text cleaner stripped everything (e.g. a message made only of emojis/whitespace filtered by sanitize); batch pipeline passes an empty row from a spreadsheet.","solutions":["Provide non-empty text to synthesize; check the text field before clicking generate / before calling run().","In calling code, strip and early-return when text is blank: if not (text or '').strip(): return no-op.","For API servers, validate the text payload and return 400 with a clear message instead of surfacing this traceback."],"exampleFix":"# before\naudio = handler.run(text=\"\\n \\n\", text_lang=\"zh\", ...)  # ValueError: 请输入有效文本\n\n# after\ntext = (raw_text or \"\").strip()\nif not text:\n    raise HTTPBadRequest(\"text is required\")\naudio = handler.run(text=text, text_lang=\"zh\", ...)","handlingStrategy":"validation","validationCode":"if not any((t or \"\").strip() for t in texts):\n    raise ValueError(\"no non-blank text to synthesize\")","typeGuard":"def has_synthable_text(texts: list[str | None]) -> bool:\n    return any(t is not None and t.strip() and t.strip() != \"\\n\" for t in texts)","tryCatchPattern":null,"preventionTips":["Strip and check text before calling run(); return early on blank input.","Disable generate buttons until text is non-blank in UIs.","Map this ValueError to HTTP 400 with a clear message in API layers."],"tags":["text-validation","empty-input","tts","preprocessing"],"backgroundTag":null,"analyzedSha":"d523079fc05d9a8028d6085bffe4a2757c32abb6","analyzedAt":"2026-08-15T01:06:46.402Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}