Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add load_custom_phonemes() #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

veelion
Copy link

@veelion veelion commented Jan 5, 2023

For many technical terms, e.g. "AI", "GitHub", phonemes converted by seq2se2 are not the right pronunciation, so a custom dict is necessary.

The added method load_custom_phonemes(self, file_path) to G2p, reads a cmudict like file to self.cmu. usage:

from g2p_en import G2p

texts = [
        "AI is popular on GitHub.",
        ]
g2p = G2p()
for text in texts:
    out = g2p(text)
    print(out)

g2p.load_custom_phonemes('./z-custom')
for text in texts:
    out = g2p(text)
    print(out)

['AY1', ' ', 'IH1', 'Z', ' ', 'P', 'AA1', 'P', 'Y', 'AH0', 'L', 'ER0', ' ', 'AA1', 'N', ' ', 'G', 'IH1', 'TH', 'AH0', 'B', ' ', '.']
['EY1', 'AY1', ' ', 'IH1', 'Z', ' ', 'P', 'AA1', 'P', 'Y', 'AH0', 'L', 'ER0', ' ', 'AA1', 'N', ' ', 'G', 'IH0', 'T', 'HH', 'AH1', 'B', ' ', '.']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant