mirror of
https://github.com/FunAudioLLM/CosyVoice.git
synced 2026-02-04 17:39:25 +08:00
Update frontend_utils.py
"Fix the bug in `split_paragraph` where the last sentence of synthesized text with multiple paragraphs loses punctuation, causing it to be lost."
This commit is contained in:
@@ -80,6 +80,13 @@ def split_paragraph(text: str, tokenize, lang="zh", token_max_n=80, token_min_n=
|
|||||||
pounc = ['.', '?', '!', ';', ':']
|
pounc = ['.', '?', '!', ';', ':']
|
||||||
if comma_split:
|
if comma_split:
|
||||||
pounc.extend([',', ','])
|
pounc.extend([',', ','])
|
||||||
|
|
||||||
|
if text[-1] not in pounc:
|
||||||
|
if lang == "zh":
|
||||||
|
text += "。"
|
||||||
|
else:
|
||||||
|
text += "."
|
||||||
|
|
||||||
st = 0
|
st = 0
|
||||||
utts = []
|
utts = []
|
||||||
for i, c in enumerate(text):
|
for i, c in enumerate(text):
|
||||||
@@ -92,11 +99,7 @@ def split_paragraph(text: str, tokenize, lang="zh", token_max_n=80, token_min_n=
|
|||||||
st = i + 2
|
st = i + 2
|
||||||
else:
|
else:
|
||||||
st = i + 1
|
st = i + 1
|
||||||
if len(utts) == 0:
|
|
||||||
if lang == "zh":
|
|
||||||
utts.append(text + '。')
|
|
||||||
else:
|
|
||||||
utts.append(text + '.')
|
|
||||||
final_utts = []
|
final_utts = []
|
||||||
cur_utt = ""
|
cur_utt = ""
|
||||||
for utt in utts:
|
for utt in utts:
|
||||||
|
|||||||
Reference in New Issue
Block a user