g2p-arpabet


Nameg2p-arpabet JSON
Version 2.3.0 PyPI version JSON
download
home_page
SummaryA Simple Python Module for English Grapheme To Phoneme Conversion
upload_time2023-07-08 02:05:38
maintainer
docs_urlNone
authorKyubyong Park
requires_python>=3.9,<4.0
licenseApache License
keywords g2p g2p_en
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![image](https://img.shields.io/pypi/v/g2p-en.svg)](https://pypi.org/project/g2p-en/)
[![image](https://img.shields.io/pypi/l/g2p-en.svg)](https://pypi.org/project/g2p-en/)

# g2pE: A Simple Python Module for English Grapheme To Phoneme Conversion

* [v.2.0] 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](https://wordspy.com/index.php?word=activationist])

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

1. Spells out arabic numbers and some currency symbols. (e.g. $200 -> two hundred dollars) (This is borrowed from [Keith Ito's code](https://github.com/keithito/tacotron/blob/master/text/numbers.py))
2. Attempts to retrieve the correct pronunciation for heteronyms based on their POS)
3. Looks up [The CMU Pronouncing Dictionary](http://www.speech.cs.cmu.edu/cgi-bin/cmudict) for non-homographs.
4. 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', ' ', '.']

## References

If you use this code for research, please cite:

```
@misc{g2pE2019,
  author = {Park, Kyubyong & Kim, Jongseok},
  title = {g2pE},
  year = {2019},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/Kyubyong/g2p}}
}
```

## Cited in
* [Learning pronunciation from a foreign language in speech synthesis networks](https://arxiv.org/abs/1811.09364)

May, 2018.

Kyubyong Park & [Jongseok Kim](https://github.com/ozmig77)

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "g2p-arpabet",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9,<4.0",
    "maintainer_email": "",
    "keywords": "g2p,g2p_en",
    "author": "Kyubyong Park",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/e1/cd/f94fe3cda829da262a6651b14ba75284cdd0a88cd8945ab300259ba914fa/g2p_arpabet-2.3.0.tar.gz",
    "platform": null,
    "description": "[![image](https://img.shields.io/pypi/v/g2p-en.svg)](https://pypi.org/project/g2p-en/)\n[![image](https://img.shields.io/pypi/l/g2p-en.svg)](https://pypi.org/project/g2p-en/)\n\n# g2pE: A Simple Python Module for English Grapheme To Phoneme Conversion\n\n* [v.2.0] 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.\n\nThis module is designed to convert English graphemes (spelling) to phonemes (pronunciation).\nIt is considered essential in several tasks such as speech synthesis.\nUnlike many languages like Spanish or German where pronunciation of a word can be inferred from its spelling,\nEnglish words are often far from people's expectations.\nTherefore, it will be the best idea to consult a dictionary if we want to know the pronunciation of some word.\nHowever, there are at least two tentative issues in this approach.\nFirst, you can't disambiguate the pronunciation of homographs, words which have multiple pronunciations. (See `a` below.)\nSecond, you can't check if the word is not in the dictionary. (See `b` below.)\n\n* a. I refuse to collect the refuse around here. (r\u026a|fju:z as verb vs. |refju:s as noun)\n* 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.`\nfrom [WORD SPY](https://wordspy.com/index.php?word=activationist])\n\nFor the first homograph issue, fortunately many homographs can be disambiguated using their part-of-speech, if not all.\nWhen it comes to the words not in the dictionary, however, we should make our best guess using our knowledge.\nIn this project, we employ a deep learning seq2seq framework based on TensorFlow.\n\n## Algorithm\n\n1. Spells out arabic numbers and some currency symbols. (e.g. $200 -> two hundred dollars) (This is borrowed from [Keith Ito's code](https://github.com/keithito/tacotron/blob/master/text/numbers.py))\n2. Attempts to retrieve the correct pronunciation for heteronyms based on their POS)\n3. Looks up [The CMU Pronouncing Dictionary](http://www.speech.cs.cmu.edu/cgi-bin/cmudict) for non-homographs.\n4. For OOVs, we predict their pronunciations using our neural net model.\n\n## Environment\n\n* python 3.x\n\n## Dependencies\n\n* numpy >= 1.13.1\n* nltk >= 3.2.4\n* python -m nltk.downloader \"averaged_perceptron_tagger\" \"cmudict\"\n* inflect >= 0.3.1\n* Distance >= 0.1.3\n\n## Installation\n\n    pip install g2p_en\nOR\n\n    python setup.py install\n\nnltk package will be automatically downloaded at your first run.\n\n\n## Usage\n\n    from g2p_en import G2p\n    \n    texts = [\"I have $250 in my pocket.\", # number -> spell-out\n             \"popular pets, e.g. cats and dogs\", # e.g. -> for example\n             \"I refuse to collect the refuse around here.\", # homograph\n             \"I'm an activationist.\"] # newly coined word\n    g2p = G2p()\n    for text in texts:\n        out = g2p(text)\n        print(out)\n    >>> ['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', ' ', '.']\n    >>> ['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']\n    >>> ['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', ' ', '.']\n    >>> ['AY1', ' ', 'AH0', 'M', ' ', 'AE1', 'N', ' ', 'AE2', 'K', 'T', 'IH0', 'V', 'EY1', 'SH', 'AH0', 'N', 'IH0', 'S', 'T', ' ', '.']\n\n## References\n\nIf you use this code for research, please cite:\n\n```\n@misc{g2pE2019,\n  author = {Park, Kyubyong & Kim, Jongseok},\n  title = {g2pE},\n  year = {2019},\n  publisher = {GitHub},\n  journal = {GitHub repository},\n  howpublished = {\\url{https://github.com/Kyubyong/g2p}}\n}\n```\n\n## Cited in\n* [Learning pronunciation from a foreign language in speech synthesis networks](https://arxiv.org/abs/1811.09364)\n\nMay, 2018.\n\nKyubyong Park & [Jongseok Kim](https://github.com/ozmig77)\n",
    "bugtrack_url": null,
    "license": "Apache License",
    "summary": "A Simple Python Module for English Grapheme To Phoneme Conversion",
    "version": "2.3.0",
    "project_urls": null,
    "split_keywords": [
        "g2p",
        "g2p_en"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f818610282926f108327f57f71b35d77729267e58f7c95b8fc66d8ea59fbc073",
                "md5": "412ce5d1ed62165cb26c636f59285d1c",
                "sha256": "52e19279c66ab2c77275ab817286ef0c113a00fd06a123c1f88e6b53138f87fd"
            },
            "downloads": -1,
            "filename": "g2p_arpabet-2.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "412ce5d1ed62165cb26c636f59285d1c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9,<4.0",
            "size": 3119126,
            "upload_time": "2023-07-08T02:05:33",
            "upload_time_iso_8601": "2023-07-08T02:05:33.679227Z",
            "url": "https://files.pythonhosted.org/packages/f8/18/610282926f108327f57f71b35d77729267e58f7c95b8fc66d8ea59fbc073/g2p_arpabet-2.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e1cdf94fe3cda829da262a6651b14ba75284cdd0a88cd8945ab300259ba914fa",
                "md5": "b73509ff9a0fc3b353ac30ce174f5865",
                "sha256": "bd9dadec962bb98e181c0e605ee38f32fe4018007e25ad589be711f8a911df36"
            },
            "downloads": -1,
            "filename": "g2p_arpabet-2.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "b73509ff9a0fc3b353ac30ce174f5865",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<4.0",
            "size": 3120758,
            "upload_time": "2023-07-08T02:05:38",
            "upload_time_iso_8601": "2023-07-08T02:05:38.295893Z",
            "url": "https://files.pythonhosted.org/packages/e1/cd/f94fe3cda829da262a6651b14ba75284cdd0a88cd8945ab300259ba914fa/g2p_arpabet-2.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-08 02:05:38",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "g2p-arpabet"
}
        
Elapsed time: 0.08508s