{"id":27765,"library":"g2p-mix","title":"g2p-mix","description":"A grapheme-to-phoneme conversion library with mixed models (rule-based and neural). Version 0.6.5. Irregular releases.","status":"active","version":"0.6.5","language":"python","source_language":"en","source_url":"https://github.com/pengzhendong/g2p-mix","tags":["g2p","phoneme","chinese","tts","nlp"],"install":[{"cmd":"pip install g2p-mix","lang":"bash","label":"pip"}],"dependencies":[{"reason":"Required for Chinese pinyin conversion","package":"pypinyin","optional":false},{"reason":"Required for Chinese number-to-article conversion","package":"cn2an","optional":false},{"reason":"Dictionary data for pinyin","package":"pypinyin-dict","optional":true}],"imports":[{"note":"Correct import path uses underscore, not hyphen","symbol":"G2pMix","correct":"from g2p_mix import G2pMix"},{"note":"Hyphen in package name is not valid Python identifier","wrong":"from g2p-mix import G2pMix","symbol":"G2pMix","correct":"from g2p_mix import G2pMix"}],"quickstart":{"code":"from g2p_mix import G2pMix\n\ng2p = G2pMix()\ntext = \"中华人民共和国于1949年成立。\"\nresult = g2p(text)\nprint(result)","lang":"python","description":"Initialize G2pMix and convert Chinese text to phonemes."},"warnings":[{"fix":"Access phonemes via dict keys (e.g., result[0]['phonemes']) instead of tuple indexing.","message":"In version 0.5.x, the return format changed from list of tuples to list of dicts. Code relying on tuple unpacking will break.","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Pre-process text to ensure only Chinese characters are passed, or handle non-Chinese separately.","message":"Non-Chinese characters (e.g., English letters, digits) may be silently dropped or converted incorrectly. The library is designed primarily for Chinese text.","severity":"gotcha","affected_versions":"all"},{"fix":"Set environment variable G2PMIX_DATA_DIR to a custom path to control cache location.","message":"The default model may require downloading data on first run, which can be slow and may fail behind a proxy.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Use 'from g2p_mix import G2pMix' (underscore, not hyphen).","cause":"Installed package named 'g2p-mix' but import uses underscore.","error":"ModuleNotFoundError: No module named 'g2p_mix'"},{"fix":"Upgrade: pip install --upgrade g2p-mix","cause":"Outdated installation or different version where class name changed.","error":"ImportError: cannot import name 'G2pMix' from 'g2p_mix'"},{"fix":"Update result access: result[0]['phonemes'] instead of phoneme, tone = result[0]","cause":"Old code expects tuple (phoneme, tone) but newer version returns dict.","error":"ValueError: not enough values to unpack (expected 2, got 1)"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}