2021-04-22 17:20:34 +08:00
|
|
|
from pypinyin import lazy_pinyin, Style
|
2021-04-02 11:06:34 +08:00
|
|
|
from typing import List
|
|
|
|
|
|
|
|
|
|
|
|
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
|