From c32813913bf11446d65ec8f0fbdfe9c9acd05a59 Mon Sep 17 00:00:00 2001 From: fangzhehao Date: Mon, 9 Dec 2024 11:36:33 +0800 Subject: [PATCH] =?UTF-8?q?api=5Fv2=20=E6=94=AF=E6=8C=81=E5=A4=9A=E9=9F=B3?= =?UTF-8?q?=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GPT_SoVITS/TTS_infer_pack/TextPreprocessor.py | 1 + GPT_SoVITS/text/chinese2.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/GPT_SoVITS/TTS_infer_pack/TextPreprocessor.py b/GPT_SoVITS/TTS_infer_pack/TextPreprocessor.py index b90bd929..ddd176b0 100644 --- a/GPT_SoVITS/TTS_infer_pack/TextPreprocessor.py +++ b/GPT_SoVITS/TTS_infer_pack/TextPreprocessor.py @@ -117,6 +117,7 @@ class TextPreprocessor: return self.get_phones_and_bert(text, language, version) def get_phones_and_bert(self, text:str, language:str, version:str, final:bool=False): + LangSegment.setKeepPinyin(True) if language in {"en", "all_zh", "all_ja", "all_ko", "all_yue"}: language = language.replace("all_","") if language == "en": diff --git a/GPT_SoVITS/text/chinese2.py b/GPT_SoVITS/text/chinese2.py index b98a6ee0..cc359c48 100644 --- a/GPT_SoVITS/text/chinese2.py +++ b/GPT_SoVITS/text/chinese2.py @@ -177,6 +177,9 @@ def _g2p(segments): # assert len(sub_initials) == len(sub_finals) == len(word) initials = sum(initials, []) finals = sum(finals, []) + initials=[to_initials(customer_pinyin[index]) if customer_pinyin[index] != "" else item for index,item in enumerate(initials)] + finals=[to_finals_tone3(customer_pinyin[index]) if customer_pinyin[index] != "" else item for index,item in enumerate(finals)] + print("customer_pinyin:",customer_pinyin) print("pypinyin结果",initials,finals) else: # g2pw采用整句推理 @@ -215,7 +218,7 @@ def _g2p(segments): initials = sum(initials, []) finals = sum(finals, []) - # print("g2pw结果",initials,finals) + print("g2pw结果",initials,finals) for c, v in zip(initials, finals): raw_pinyin = c + v