INNER CODE UNIT · Python
g2p_cn_en
netease-youdao/EmotiVoice · frontend.py:23
def g2p_cn_en(text, g2p, lexicon):
# Our policy dictates that if the text contains Chinese, digits are to be converted into Chinese.
text=tn_chinese(text)
parts = re_english_word.split(text)
parts=list(filter(None, parts))
tts_text = ["<sos/eos>"]
chartype = ''
text_contains_chinese = contains_chinese(text)
for part in parts:
if part == ' ' or part == '': continue
if re_digits.match(part) and (text_contains_chinese or chartype == '') or contains_chinese(part):
if chartype == 'en':
tts_text.append('eng_cn_sp')
phoneme = g2p_cn(part).split()[1:-1]
chartype = 'cn'
elif re_english_word.match(part):
if chartype == 'cn':
if "sp" in tts_text[-1]: