From 6ae6ba3f779f1bd13f050f5b854fe58cb123caaa Mon Sep 17 00:00:00 2001 From: zhuyunfeng <42790740+zhuzizyf@users.noreply.github.com> Date: Sun, 14 Jul 2024 22:33:56 +0800 Subject: [PATCH] Update frontend.py Fix the bug in handling anomalies for synthetic text ending with Chinese and English commas. --- cosyvoice/cli/frontend.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cosyvoice/cli/frontend.py b/cosyvoice/cli/frontend.py index 0fb9ca9..3ed8550 100644 --- a/cosyvoice/cli/frontend.py +++ b/cosyvoice/cli/frontend.py @@ -20,6 +20,7 @@ from typing import Callable import torchaudio.compliance.kaldi as kaldi import torchaudio import os +import re import inflect try: import ttsfrd @@ -110,6 +111,7 @@ class CosyVoiceFrontEnd: text = text.replace(".", "、") text = text.replace(" - ", ",") text = remove_bracket(text) + text = re.sub(r'[,,]+$', '。', text) texts = [i for i in split_paragraph(text, partial(self.tokenizer.encode, allowed_special=self.allowed_special), "zh", token_max_n=80, token_min_n=60, merge_len=20, comma_split=False)]