ParakeetRebeccaRosario/examples/tacotron2_aishell3/chinese_text_to_pinyin.py

14 lines
416 B
Python
Raw Normal View History

2021-04-02 11:06:34 +08:00
from typing import List
2021-04-28 20:02:29 +08:00
from pypinyin import lazy_pinyin, Style
2021-04-02 11:06:34 +08:00
def convert_to_pinyin(text: str) -> List[str]:
"""convert text into list of syllables, other characters that are not chinese, thus
cannot be converted to pinyin are splited.
"""
2021-04-22 17:20:34 +08:00
syllables = lazy_pinyin(text,
style=Style.TONE3,
neutral_tone_with_five=True)
2021-04-02 11:06:34 +08:00
return syllables