espnet2.text.phoneme_tokenizer.G2p_en
Less than 1 minute
espnet2.text.phoneme_tokenizer.G2p_en
class espnet2.text.phoneme_tokenizer.G2p_en(no_space: bool = False)
Bases: object
On behalf of g2p_en.G2p.
This class serves as a wrapper for the g2p_en.G2p class, which is used for converting English text to phonemes. Note that g2p_en.G2p is not picklable, meaning it cannot be serialized for use with the multiprocessing module. As a workaround, an instance of g2p_en.G2p is created upon the first call to this class.
no_space
If True, spaces representing word separators will be removed from the output.
Type: bool
Parameters:no_space (bool) – Flag indicating whether to remove spaces from the phoneme output. Default is False.
Returns: A list of phonemes corresponding to the input text.
Return type: List[str]
Examples
>>> g2p = G2p_en(no_space=True)
>>> phonemes = g2p("Hello world")
>>> print(phonemes)
['h', 'ə', 'l', 'oʊ', 'w', 'ɜ', 'r', 'l', 'd']