修复选择按照标点符号分句时候,如果合成文本中句尾没有标点符号就报错的问题

This commit is contained in:
Erythrocyte3803 2024-01-29 13:02:25 +09:00
parent 5673473ec4
commit bde767dad8
4 changed files with 23 additions and 1 deletions

View File

@ -246,7 +246,6 @@ def nonen_clean_text_inf(text, language):
return phones, word2ph, norm_text return phones, word2ph, norm_text
def nonen_get_bert_inf(text, language): def nonen_get_bert_inf(text, language):
textlist, langlist = splite_en_inf(text, language) textlist, langlist = splite_en_inf(text, language)
print(textlist) print(textlist)
@ -446,6 +445,8 @@ def cut4(inp):
return "\n".join(["%s." % item for item in inp.strip(".").split(".")]) return "\n".join(["%s." % item for item in inp.strip(".").split(".")])
def cut5(inp): def cut5(inp):
if not re.search(r'[^\w\s]', inp[-1]):
inp += ''
inp = inp.strip("\n") inp = inp.strip("\n")
punds = r'[、,。?!;]' punds = r'[、,。?!;]'
items = re.split(f'({punds})', inp) items = re.split(f'({punds})', inp)
@ -454,6 +455,8 @@ def cut5(inp):
return opt return opt
def cut6(inp): def cut6(inp):
if not re.search(r'[^\w\s]', inp[-1]):
inp += '.'
inp = inp.strip("\n") inp = inp.strip("\n")
punds = r'[,.;?!]' punds = r'[,.;?!]'
items = re.split(f'({punds})', inp) items = re.split(f'({punds})', inp)

1
gweight.txt Normal file
View File

@ -0,0 +1 @@
GPT_weights/na_xi_da-e50.ckpt

1
sweight.txt Normal file
View File

@ -0,0 +1 @@
SoVITS_weights/na_xi_da_e20_s2020.pth

17
test.py Normal file
View File

@ -0,0 +1,17 @@
import re
def add_period(text):
if not re.search(r'[^\w\s]', text[-1]):
text += ''
return text
def cut5(inp):
inp = add_period(inp)
inp = inp.strip("\n")
punds = r'[、,。?!;]'
items = re.split(f'({punds})', inp)
items = ["".join(group) for group in zip(items[::2], items[1::2])]
opt = "\n".join(items)
return opt
print(cut5("测试"))