pre_seg_text开头加入判断是否全是特殊字符,并防止text为空字符,更改多个换行符的替换的代码 #962
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
修改GPT_SoVITS/TTS_infer_pack/TextPreprocessor.py 中的 pre-seg-text函数以修复一些bug
在text = text.strip("\n")
后面加入 if not re.sub('\W','', text): text ='' ,如果text都是特殊字符,则记为空字符串。
text.strip后可能得到空字符串,导致使用text[0]出错。所以判断text是否为空,防止text为空字符串时候使用text[0]。
使用正则式text = re.sub(r'\n+','\n', text)
来替换原来的 while "\n\n" in text: text = text.replace("\n\n", "\n")。