espnet2.text.phoneme_tokenizer.pypinyin_g2p_phone
Less than 1 minute
espnet2.text.phoneme_tokenizer.pypinyin_g2p_phone
espnet2.text.phoneme_tokenizer.pypinyin_g2p_phone(text) → List[str]
Convert Chinese text to phonemes using Pinyin with tone markings.
This function takes a Chinese text input and converts it into a list of phonemes based on the Pinyin representation, including initial and final sounds, while maintaining tone information. The function is useful for applications requiring phonetic analysis or text-to-speech systems.
- Parameters:text (str) – The input Chinese text to be converted to phonemes.
- Returns: A list of phonemes extracted from the input text.
- Return type: List[str]
Examples
>>> pypinyin_g2p_phone("你好")
['n', 'i', 'h', 'a', 'o']
>>> pypinyin_g2p_phone("北京")
['b', 'e', 'i', 'j', 'i', 'n']
NOTE
This function utilizes the pypinyin library, which must be installed for the function to work correctly. Ensure to handle any potential exceptions that may arise from invalid input.