INNER CODE UNIT · Python
g2p_cn
netease-youdao/EmotiVoice · frontend_cn.py:102
def g2p_cn(text):
res_text=["<sos/eos>"]
seg_list = jieba.cut(text)
for seg in seg_list:
if seg == " ": continue
seg_tn = tn_chinese(seg)
py =[_py[0] for _py in pinyin(seg_tn, style=Style.TONE3,neutral_tone_with_five=True)]
if any([has_chinese_punctuation(_py) for _py in py]) or any([has_english_punctuation(_py) for _py in py]):
res_text.pop()
res_text.append("sp3")
else:
py = [" ".join(split_py(_py)) for _py in py]
res_text.append(" sp0 ".join(py))
res_text.append("sp1")
#res_text.pop()