espnet2.text.phoneme_tokenizer.pypinyin_g2p
Less than 1 minute
espnet2.text.phoneme_tokenizer.pypinyin_g2p
espnet2.text.phoneme_tokenizer.pypinyin_g2p(text) → List[str]
Convert Chinese text to pinyin phonemes.
This function utilizes the pypinyin library to convert the given Chinese text into its corresponding pinyin phonemes. It extracts the pinyin with tone numbers, returning them as a list of strings.
- Parameters:text (str) – The Chinese text to be converted into pinyin.
- Returns: A list of pinyin phonemes corresponding to the input text.
- Return type: List[str]
Examples
>>> pypinyin_g2p("你好")
['nǐ', 'hǎo']
>>> pypinyin_g2p("中国")
['zhōng', 'guó']
NOTE
Ensure that the pypinyin library is installed in your environment.