This is an unofficial republication of Kyubyong/g2p maintained by the ESPnet project. It is not affiliated with, nor endorsed by, the original authors. It exists because upstream’s last release (2.1.0, December 2019) asks NLTK for averaged_perceptron_tagger, which NLTK 3.8.2 renamed to averaged_perceptron_tagger_eng, so import g2p_en fails on any current NLTK. The import name is unchanged. See FORK_NOTICE.md.
g2p_en: A Simple Python Module for English Grapheme To Phoneme Conversion
[Update] * We removed TensorFlow from the dependencies. After all, it changes its APIs quite often, and we don’t expect you to have a GPU. Instead, NumPy is used for inference.
This module is designed to convert English graphemes (spelling) to phonemes (pronunciation). It is considered essential in several tasks such as speech synthesis. Unlike many languages like Spanish or German where pronunciation of a word can be inferred from its spelling, English words are often far from people’s expectations. Therefore, it will be the best idea to consult a dictionary if we want to know the pronunciation of some word. However, there are at least two tentative issues in this approach. First, you can’t disambiguate the pronunciation of homographs, words which have multiple pronunciations. (See a below.) Second, you can’t check if the word is not in the dictionary. (See b below.)
a. I refuse to collect the refuse around here. (rɪ|fju:z as verb vs. |refju:s as noun)
b. I am an activationist. (activationist: newly coined word which means n. A person who designs and implements programs of treatment or therapy that use recreation and activities to help people whose functional abilities are affected by illness or disability. from WORD SPY
For the first homograph issue, fortunately many homographs can be disambiguated using their part-of-speech, if not all. When it comes to the words not in the dictionary, however, we should make our best guess using our knowledge. In this project, we employ a deep learning seq2seq framework based on TensorFlow.
Algorithm
Spells out arabic numbers and some currency symbols. (e.g. $200 -> two hundred dollars) (This is borrowed from Keith Ito’s code)
Attempts to retrieve the correct pronunciation for homographs based on their POS)
Looks up The CMU Pronouncing Dictionary for non-homographs.
For OOVs, we predict their pronunciations using our neural net model.
Environment
python 3.x
Dependencies
numpy >= 1.13.1
nltk >= 3.2.4
python -m nltk.downloader “averaged_perceptron_tagger” “cmudict”
inflect >= 0.3.1
Distance >= 0.1.3
Installation
pip install g2p_en
OR
python setup.py install
nltk package will be automatically downloaded at your first run.
Usage
from g2p_en import G2p
texts = ["I have $250 in my pocket.", # number -> spell-out
"popular pets, e.g. cats and dogs", # e.g. -> for example
"I refuse to collect the refuse around here.", # homograph
"I'm an activationist."] # newly coined word
g2p = G2p()
for text in texts:
out = g2p(text)
print(out)
>>> ['AY1', ' ', 'HH', 'AE1', 'V', ' ', 'T', 'UW1', ' ', 'HH', 'AH1', 'N', 'D', 'R', 'AH0', 'D', ' ', 'F', 'IH1', 'F', 'T', 'IY0', ' ', 'D', 'AA1', 'L', 'ER0', 'Z', ' ', 'IH0', 'N', ' ', 'M', 'AY1', ' ', 'P', 'AA1', 'K', 'AH0', 'T', ' ', '.']
>>> ['P', 'AA1', 'P', 'Y', 'AH0', 'L', 'ER0', ' ', 'P', 'EH1', 'T', 'S', ' ', ',', ' ', 'F', 'AO1', 'R', ' ', 'IH0', 'G', 'Z', 'AE1', 'M', 'P', 'AH0', 'L', ' ', 'K', 'AE1', 'T', 'S', ' ', 'AH0', 'N', 'D', ' ', 'D', 'AA1', 'G', 'Z']
>>> ['AY1', ' ', 'R', 'IH0', 'F', 'Y', 'UW1', 'Z', ' ', 'T', 'UW1', ' ', 'K', 'AH0', 'L', 'EH1', 'K', 'T', ' ', 'DH', 'AH0', ' ', 'R', 'EH1', 'F', 'Y', 'UW2', 'Z', ' ', 'ER0', 'AW1', 'N', 'D', ' ', 'HH', 'IY1', 'R', ' ', '.']
>>> ['AY1', ' ', 'AH0', 'M', ' ', 'AE1', 'N', ' ', 'AE2', 'K', 'T', 'IH0', 'V', 'EY1', 'SH', 'AH0', 'N', 'IH0', 'S', 'T', ' ', '.']
May, 2018.
Kyubyong Park & Jongseok Kim
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file espnet_g2p_en-2.1.0.post1.tar.gz.
File metadata
- Download URL: espnet_g2p_en-2.1.0.post1.tar.gz
- Upload date:
- Size: 3.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e04d24a36e6e0a55a926e11a2fb4e9d70c6695aec80251287ddcb7183cbd336
|
|
| MD5 |
a88e30cd19f93e3e147ff7ca607523b3
|
|
| BLAKE2b-256 |
4de342ccc010b6381ba25d0b0ecd846086e94bca84d776492ffea18cb7fb89db
|
Provenance
The following attestation bundles were made for espnet_g2p_en-2.1.0.post1.tar.gz:
Publisher:
publish_python_package.yml on espnet/g2p
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
espnet_g2p_en-2.1.0.post1.tar.gz -
Subject digest:
8e04d24a36e6e0a55a926e11a2fb4e9d70c6695aec80251287ddcb7183cbd336 - Sigstore transparency entry: 2685288103
- Sigstore integration time:
-
Permalink:
espnet/g2p@5f0bf457999e4bc4a8266b5248ea34e49e7952b7 -
Branch / Tag:
refs/tags/v2.1.0.post1 - Owner: https://github.com/espnet
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_python_package.yml@5f0bf457999e4bc4a8266b5248ea34e49e7952b7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file espnet_g2p_en-2.1.0.post1-py3-none-any.whl.
File metadata
- Download URL: espnet_g2p_en-2.1.0.post1-py3-none-any.whl
- Upload date:
- Size: 3.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7108dd7e5a542764ae024b8528f559ffe3da13d857d427921c06c9ccf2ac5f32
|
|
| MD5 |
6a95b1baccddd1cf85df57f5aa56bd5b
|
|
| BLAKE2b-256 |
3b03900ec5b4f881c6d51abc89efddb14608edb3292cea42767fc02bb1621773
|
Provenance
The following attestation bundles were made for espnet_g2p_en-2.1.0.post1-py3-none-any.whl:
Publisher:
publish_python_package.yml on espnet/g2p
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
espnet_g2p_en-2.1.0.post1-py3-none-any.whl -
Subject digest:
7108dd7e5a542764ae024b8528f559ffe3da13d857d427921c06c9ccf2ac5f32 - Sigstore transparency entry: 2685288129
- Sigstore integration time:
-
Permalink:
espnet/g2p@5f0bf457999e4bc4a8266b5248ea34e49e7952b7 -
Branch / Tag:
refs/tags/v2.1.0.post1 - Owner: https://github.com/espnet
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_python_package.yml@5f0bf457999e4bc4a8266b5248ea34e49e7952b7 -
Trigger Event:
push
-
Statement type: