Registry / ai-ml / g2p
library2.3.1pypypi✓ verified 90d ago

Context-aware, rule-based grapheme-to-phoneme (G2P) mapping library that preserves indices. Version 2.3.1 (stable, as of 2025). Maintained by NRC-ILT. Monthly releases.

pip install g2p
INSTALL
IMPORT
SIG · G2P
G
g2p
ai-mlpythonv2.3.1
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.

make_g2p
✓ from g2p import make_g2p
✗ from g2p.mappings import make_g2p
make_g2p moved to top-level in v2.0
Token
✓ from g2p import Token
✗ from g2p.tokenizer import Token
Token is exported from g2p package since v2.0

Basic usage: load a built-in mapping and convert text.

from g2p import make_g2p # Create a mapping from English to IPA mapper = make_g2p('eng-ipa', tokenize=True) # Convert text result = mapper('Hello world') print(result.output_string) # 'hɛˈloʊ wɜrld' (approximate)
Debug
Known issues
breakingv2.0 changed the mapping configuration file format and the programmatic API. Old 1.x mappings are incompatible. See migration guide at https://roedoejet.github.io/g2p/latest/migration-2/
fix
Rewrite mappings for v2.x. Use make_g2p() instead of direct G2P class.
affects: >=2.0.0
deprecatedmake_g2p(in, out) used to not tokenize by default; now it does. The tok_lang argument is deprecated.
fix
Use tokenize=True/False instead of tok_lang. If you need to disable tokenization, pass tokenize=False.
affects: >=2.0.0
gotchaThe first import of g2p loads a 45MB lexicon (for English), causing a ~2s import delay. This is expected.
fix
Consider lazy-loading or using a non-English mapping to avoid the delay.
affects: >=2.1.0
Errors
Common errors & fixes
ImportError: cannot import name 'make_g2p' from 'g2p'
Using an older version (1.x) where make_g2p didn't exist or was in a different location.
fix
Upgrade to g2p>=2.0 and use 'from g2p import make_g2p'.
ModuleNotFoundError: No module named 'networkx'
Before v2.1.1, g2p used networkx as a dependency. In v2.1.1+, it was replaced with a custom class, but if you have an old lock file or install from source, networkx may be missing.
fix
Upgrade to g2p>=2.1.1 or install networkx manually: pip install networkx.
Upgrade
Version history
2.3.1latest on PyPI · released Jan 26, 2026
Audit
Dependencies
pydanticrequiredData validation (>=2)
Agent activity
15 hits · last 30 days
node
12
OpenAI (training)
1
Resources
g2p — pip install g2p · libregistry