Registry / ai-ml / g2p-mix

g2p-mix

JSON →
library0.6.5pypypi✓ verified 85d ago

A grapheme-to-phoneme conversion library with mixed models (rule-based and neural). Version 0.6.5. Irregular releases.

pip install g2p-mix
INSTALL
IMPORT
SIG · G2P-MIX
G
g2p-mix
ai-mlpythonv0.6.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

G2pMix
from g2p_mix import G2pMix
Correct import path uses underscore, not hyphen
G2pMix
from g2p_mix import G2pMix
from g2p-mix import G2pMix
Hyphen in package name is not valid Python identifier

Initialize G2pMix and convert Chinese text to phonemes.

from g2p_mix import G2pMix g2p = G2pMix() text = "中华人民共和国于1949年成立。" result = g2p(text) print(result)
Debug
Known issues
breakingIn version 0.5.x, the return format changed from list of tuples to list of dicts. Code relying on tuple unpacking will break.
fix
Access phonemes via dict keys (e.g., result[0]['phonemes']) instead of tuple indexing.
affects: >=0.5.0
gotchaNon-Chinese characters (e.g., English letters, digits) may be silently dropped or converted incorrectly. The library is designed primarily for Chinese text.
fix
Pre-process text to ensure only Chinese characters are passed, or handle non-Chinese separately.
affects: all
gotchaThe default model may require downloading data on first run, which can be slow and may fail behind a proxy.
fix
Set environment variable G2PMIX_DATA_DIR to a custom path to control cache location.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'g2p_mix'
Installed package named 'g2p-mix' but import uses underscore.
fix
Use 'from g2p_mix import G2pMix' (underscore, not hyphen).
ImportError: cannot import name 'G2pMix' from 'g2p_mix'
Outdated installation or different version where class name changed.
fix
Upgrade: pip install --upgrade g2p-mix
ValueError: not enough values to unpack (expected 2, got 1)
Old code expects tuple (phoneme, tone) but newer version returns dict.
fix
Update result access: result[0]['phonemes'] instead of phoneme, tone = result[0]
Upgrade
Version history
0.6.5latest on PyPI · released Dec 2, 2025
Audit
Dependencies
pypinyinrequiredRequired for Chinese pinyin conversion
cn2anrequiredRequired for Chinese number-to-article conversion
pypinyin-dictoptionalDictionary data for pinyin
Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
g2p-mix — pip install g2p-mix · libregistry