Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pre_seg_text开头加入判断是否全是特殊字符,并防止text为空字符,更改多个换行符的替换的代码 #962

Open
wants to merge 2 commits into
base: fast_inference_
Choose a base branch
from

Conversation

jmaple12
Copy link

@jmaple12 jmaple12 commented Apr 11, 2024

修改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")。

在text = text.strip("\n") 后面加入判断,防止text为空字符串。
使用正则式来替换原来将\n\n换为\n的式子
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant