在pre_seg_text中加入判断,若text中都是特殊字符,则将其记为空字符串,防止后面复读。

This commit is contained in:
jmaple12 2024-04-11 22:52:17 +08:00 committed by GitHub
parent 0dd1d38c86
commit d09022ee6f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -72,9 +72,12 @@ class TextPreprocessor:
def pre_seg_text(self, text:str, lang:str, text_split_method:str):
text = text.strip("\n")
#防止text成为空字符串
#如果字符里面没有文字,视其为空字符串
if not re.sub('\W','', text):
text =''
if text:
if (text[0] not in splits and len(get_first(text)) < 4):
text = text + "" if lang != "en" else text + "."
text = "" + text if lang != "en" else "." + text
print(i18n("实际输入的目标文本:"))
print(text)