{"id":27767,"library":"g2pm","title":"g2pM - Neural Grapheme-to-Phoneme for Mandarin Chinese","description":"g2pM is a neural grapheme-to-phoneme conversion package for Mandarin Chinese, leveraging a transformer-based model to convert Chinese characters (pinyin) to phonetic symbols (bopomofo/zhuyin). Current version 0.1.2.5, released infrequently; last update in 2021.","status":"maintenance","version":"0.1.2.5","language":"python","source_language":"en","source_url":"https://github.com/kakaobrain/g2pM","tags":["g2p","mandarin","chinese","phoneme","pinyin","bopomofo"],"install":[{"cmd":"pip install g2pm","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"G2pM is a class in the g2pm module, not the module itself.","wrong":"import g2pm","symbol":"G2pM","correct":"from g2pm import G2pM"}],"quickstart":{"code":"from g2pm import G2pM\n\ng2p = G2pM()\n# Convert pinyin with tone numbers to bopomofo\nresult = g2p('wo3')\nprint(result)  # Output: ㄨㄛˇ\n\n# For a list of pinyin strings\nresults = g2p(['ni3', 'hao3'])\nprint(results)  # Output: ['ㄋㄧˇ', 'ㄏㄠˇ']","lang":"python","description":"Initialize G2pM and convert pinyin to bopomofo."},"warnings":[{"fix":"Preprocess your text to extract pinyin syllables with tone numbers before using g2pM.","message":"Input must be pinyin with tone numbers (e.g., 'ni3'), not Chinese characters or pinyin without tones. The model does not handle characters.","severity":"gotcha","affected_versions":"all"},{"fix":"Run g2p = G2pM() once to trigger download; subsequent calls use cached model.","message":"The package downloads a pre-trained model on first use (~75 MB). Ensure network connectivity or manually cache the model.","severity":"gotcha","affected_versions":"all"},{"fix":"Consider using an alternative like pypinyin or jieba for Chinese text processing.","message":"The package has not been updated since 2021 and may not work with newer Python versions (e.g., 3.10+). Known issues with tensorflow or torch dependency mismatches.","severity":"deprecated","affected_versions":"0.1.2.5"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Run: pip install g2pm","cause":"Package not installed or misspelled; sometimes confused with 'g2p' or 'g2p-en'.","error":"ModuleNotFoundError: No module named 'g2pm'"},{"fix":"Use: from g2pm import G2pM","cause":"Incorrect import pattern (e.g., 'import g2pm' then 'g2pm.G2pM()' but G2pM is not a direct attribute of the module).","error":"AttributeError: module 'g2pm' has no attribute 'G2pM'"},{"fix":"Delete the cached model directory (usually ~/.g2pm/) and re-initialize: from g2pm import G2pM; g2p = G2pM()","cause":"Model file not downloaded or corrupted because download interrupted.","error":"FileNotFoundError: [Errno 2] No such file or directory: '.../g2pm/model/model.pb'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}