{"id":27766,"library":"g2p","title":"g2p","description":"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.","status":"active","version":"2.3.1","language":"python","source_language":"en","source_url":"https://github.com/NRC-ILT/g2p","tags":["g2p","grapheme-to-phoneme","phonetics","nlp","linguistics"],"install":[{"cmd":"pip install g2p","lang":"bash","label":"pip install g2p"}],"dependencies":[{"reason":"Data validation (>=2)","package":"pydantic","optional":false}],"imports":[{"note":"make_g2p moved to top-level in v2.0","wrong":"from g2p.mappings import make_g2p","symbol":"make_g2p","correct":"from g2p import make_g2p"},{"note":"Token is exported from g2p package since v2.0","wrong":"from g2p.tokenizer import Token","symbol":"Token","correct":"from g2p import Token"}],"quickstart":{"code":"from g2p import make_g2p\n# Create a mapping from English to IPA\nmapper = make_g2p('eng-ipa', tokenize=True)\n# Convert text\nresult = mapper('Hello world')\nprint(result.output_string)\n# 'hɛˈloʊ wɜrld' (approximate)","lang":"python","description":"Basic usage: load a built-in mapping and convert text."},"warnings":[{"fix":"Rewrite mappings for v2.x. Use make_g2p() instead of direct G2P class.","message":"v2.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/","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use tokenize=True/False instead of tok_lang. If you need to disable tokenization, pass tokenize=False.","message":"make_g2p(in, out) used to not tokenize by default; now it does. The tok_lang argument is deprecated.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Consider lazy-loading or using a non-English mapping to avoid the delay.","message":"The first import of g2p loads a 45MB lexicon (for English), causing a ~2s import delay. This is expected.","severity":"gotcha","affected_versions":">=2.1.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Upgrade to g2p>=2.0 and use 'from g2p import make_g2p'.","cause":"Using an older version (1.x) where make_g2p didn't exist or was in a different location.","error":"ImportError: cannot import name 'make_g2p' from 'g2p'"},{"fix":"Upgrade to g2p>=2.1.1 or install networkx manually: pip install networkx.","cause":"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.","error":"ModuleNotFoundError: No module named 'networkx'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}