From 09c472ea9ebe50af83321aaa7a1d49bd1c64a076 Mon Sep 17 00:00:00 2001 From: duliangang Date: Sun, 28 Jan 2024 16:28:24 +0800 Subject: [PATCH] fix chinese number to pinyin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 数字转拼音不准的bug,因为将数字一个个分割了调用an2cn当然不准 --- GPT_SoVITS/text/chinese.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/GPT_SoVITS/text/chinese.py b/GPT_SoVITS/text/chinese.py index de3ef01..bb631a0 100644 --- a/GPT_SoVITS/text/chinese.py +++ b/GPT_SoVITS/text/chinese.py @@ -12,6 +12,8 @@ sys.path.append("/data/docker/liujing04/gpt-vits/gpt-vits-master") from text.symbols import punctuation from text.tone_sandhi import ToneSandhi +normalizer = lambda x: cn2an.transform(x, "an2cn") + current_file_path = os.path.dirname(__file__) pinyin_to_symbol_map = { line.split("\t")[0]: line.strip().split("\t")[1] @@ -151,10 +153,8 @@ def _g2p(segments): def text_normalize(text): - numbers = re.findall(r"\d+(?:\.?\d+)?", text) - for number in numbers: - text = text.replace(number, cn2an.an2cn(number), 1) - text = replace_punctuation(text) + dest_text=normalizer(text) + text = replace_punctuation(dest_text) return text