{"id":19398823,"url":"https://github.com/kyubyong/g2p","last_synced_at":"2025-05-15T04:08:01.806Z","repository":{"id":41173525,"uuid":"132830069","full_name":"Kyubyong/g2p","owner":"Kyubyong","description":"g2p: English Grapheme To Phoneme Conversion","archived":false,"fork":false,"pushed_at":"2023-01-05T01:52:10.000Z","size":7471,"stargazers_count":850,"open_issues_count":27,"forks_count":129,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-05-15T04:07:55.939Z","etag":null,"topics":["cmudict","english-grapheme","g2p","g2p-seq2seq","pronunciation"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Kyubyong.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-10T01:07:16.000Z","updated_at":"2025-05-12T11:17:19.000Z","dependencies_parsed_at":"2023-02-03T04:46:46.494Z","dependency_job_id":null,"html_url":"https://github.com/Kyubyong/g2p","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kyubyong%2Fg2p","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kyubyong%2Fg2p/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kyubyong%2Fg2p/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kyubyong%2Fg2p/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kyubyong","download_url":"https://codeload.github.com/Kyubyong/g2p/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254270656,"owners_count":22042860,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cmudict","english-grapheme","g2p","g2p-seq2seq","pronunciation"],"created_at":"2024-11-10T11:07:22.993Z","updated_at":"2025-05-15T04:07:56.787Z","avatar_url":"https://github.com/Kyubyong.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![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ɪ|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 -\u003e 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 \u003e= 1.13.1\n* nltk \u003e= 3.2.4\n* python -m nltk.downloader \"averaged_perceptron_tagger\" \"cmudict\"\n* inflect \u003e= 0.3.1\n* Distance \u003e= 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 -\u003e spell-out\n             \"popular pets, e.g. cats and dogs\", # e.g. -\u003e 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    \u003e\u003e\u003e ['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    \u003e\u003e\u003e ['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    \u003e\u003e\u003e ['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    \u003e\u003e\u003e ['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 \u0026 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 \u0026 [Jongseok Kim](https://github.com/ozmig77)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyubyong%2Fg2p","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkyubyong%2Fg2p","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyubyong%2Fg2p/lists"}