From d8bcc8d6b1132887a23e502f7a0ad6ab2e7b2915 Mon Sep 17 00:00:00 2001 From: XXXXRT666 Date: Sat, 8 Jun 2024 18:20:32 +0100 Subject: [PATCH] update --- GPT_SoVITS/TTS_infer_pack/TextPreprocessor.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/GPT_SoVITS/TTS_infer_pack/TextPreprocessor.py b/GPT_SoVITS/TTS_infer_pack/TextPreprocessor.py index 69576606..2cc0023c 100644 --- a/GPT_SoVITS/TTS_infer_pack/TextPreprocessor.py +++ b/GPT_SoVITS/TTS_infer_pack/TextPreprocessor.py @@ -56,6 +56,7 @@ class TextPreprocessor: def preprocess(self, text:str, lang:str, text_split_method:str)->List[Dict]: print(i18n("############ 切分文本 ############")) + texts = self.replace_consecutive_punctuation(texts) texts = self.pre_seg_text(text, lang, text_split_method) result = [] print(i18n("############ 提取文本Bert特征 ############")) @@ -213,7 +214,6 @@ class TextPreprocessor: if all(text in [None, " ", "\n",""] for text in texts): raise ValueError(i18n("请输入有效文本")) for text in texts: - text = self.replace_consecutive_punctuation(text) if text in [None, " ", ""]: pass else: @@ -223,8 +223,8 @@ class TextPreprocessor: def replace_consecutive_punctuation(self,text): punctuations = ''.join(re.escape(p) for p in punctuation) - pattern = f'[{punctuations}]{{2,}}' - result = re.sub(pattern, '.', text) + pattern = f'([{punctuations}])([{punctuations}])+' + result = re.sub(pattern, r'\1', text) return result