From 952ce4b3a3cac305fbf416bc6142cd84ae73364c Mon Sep 17 00:00:00 2001 From: Plachta Date: Wed, 1 Mar 2023 16:58:57 +0800 Subject: [PATCH] updated chinese cleaners --- text/cleaners.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/text/cleaners.py b/text/cleaners.py index 6379eb2..4a8696a 100644 --- a/text/cleaners.py +++ b/text/cleaners.py @@ -29,13 +29,19 @@ def korean_cleaners(text): return text +# def chinese_cleaners(text): +# '''Pipeline for Chinese text''' +# text = number_to_chinese(text) +# text = chinese_to_bopomofo(text) +# text = latin_to_bopomofo(text) +# text = re.sub(r'([ˉˊˇˋ˙])$', r'\1。', text) +# return text + def chinese_cleaners(text): - '''Pipeline for Chinese text''' - text = number_to_chinese(text) - text = chinese_to_bopomofo(text) - text = latin_to_bopomofo(text) - text = re.sub(r'([ˉˊˇˋ˙])$', r'\1。', text) - return text + from pypinyin import Style, pinyin + + phones = [phone[0] for phone in pinyin(text, style=Style.TONE3)] + return ' '.join(phones) def zh_ja_mixture_cleaners(text):