From dd095fe6a56652698c3c64d927ce47ad3c34530e Mon Sep 17 00:00:00 2001 From: Bono Lv Date: Tue, 22 Oct 2024 05:51:14 +0800 Subject: [PATCH] try to fix issue: https://github.com/netease-youdao/EmotiVoice/issues/164 , support version number (like 5.4.0) to chinese --- frontend_cn.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/frontend_cn.py b/frontend_cn.py index 8aabe2c..ff3fdae 100644 --- a/frontend_cn.py +++ b/frontend_cn.py @@ -85,8 +85,13 @@ def has_english_punctuation(text): re_digits = re.compile('(\d[\d\.]*)') def number_to_chinese(number): an2cn = An2Cn() - result = an2cn.an2cn(number) - + n_parts = number.split(".") + if len(n_parts) > 2: + result = an2cn.an2cn('.'.join(n_parts[:2])) + for n in n_parts[2:]: + result += an2cn.an2cn(f"0.{n}")[1:] + else: + result = an2cn.an2cn(number) return result def tn_chinese(text):