mirror of
https://github.com/RVC-Boss/GPT-SoVITS.git
synced 2025-04-24 02:16:22 +08:00
更改pre_seg_text中开头以及对多个换行符的替换
在text = text.strip("\n") 后面加入判断,防止text为空字符串。 使用正则式来替换原来将\n\n换为\n的式子
This commit is contained in:
parent
3706ad1b8b
commit
0dd1d38c86
@ -71,22 +71,24 @@ class TextPreprocessor:
|
|||||||
|
|
||||||
def pre_seg_text(self, text:str, lang:str, text_split_method:str):
|
def pre_seg_text(self, text:str, lang:str, text_split_method:str):
|
||||||
text = text.strip("\n")
|
text = text.strip("\n")
|
||||||
|
#防止text成为空字符串
|
||||||
|
if text:
|
||||||
if (text[0] not in splits and len(get_first(text)) < 4):
|
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(i18n("实际输入的目标文本:"))
|
||||||
print(text)
|
print(text)
|
||||||
|
|
||||||
seg_method = get_seg_method(text_split_method)
|
seg_method = get_seg_method(text_split_method)
|
||||||
text = seg_method(text)
|
text = seg_method(text)
|
||||||
|
|
||||||
while "\n\n" in text:
|
# while "\n\n" in text:
|
||||||
text = text.replace("\n\n", "\n")
|
# text = text.replace("\n\n", "\n")
|
||||||
|
text = re.sub(r'\n+','\n', text)
|
||||||
|
|
||||||
_texts = text.split("\n")
|
_texts = text.split("\n")
|
||||||
_texts = merge_short_text_in_array(_texts, 5)
|
_texts = merge_short_text_in_array(_texts, 5)
|
||||||
texts = []
|
texts = []
|
||||||
|
|
||||||
|
|
||||||
for text in _texts:
|
for text in _texts:
|
||||||
# 解决输入目标文本的空行导致报错的问题
|
# 解决输入目标文本的空行导致报错的问题
|
||||||
if (len(text.strip()) == 0):
|
if (len(text.strip()) == 0):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user