groʊt IPA
raw JSON → 0.13.0 verified Mon Apr 27 auth: no python
Library for manipulating pronunciations using the International Phonetic Alphabet (IPA). Provides classes and functions for parsing, grouping, and comparing IPA strings, handling suprasegmentals, diacritics, and stress markers. Current version 0.13.0.
pip install gruut-ipa Common errors
error ModuleNotFoundError: No module named 'gruut_ipa' ↓
cause Import path uses hyphen or dot instead of underscore.
fix
Use
from gruut_ipa import IPA (underscore). error AttributeError: 'IPA' object has no attribute 'graphemes' ↓
cause Renamed to `phonemes` in v0.13.0.
fix
Use
.phonemes instead. Warnings
deprecated The `IPA.graphemes` property has been removed in v0.13.0; use `.phonemes` instead. ↓
fix Replace `.graphemes` with `.phonemes`.
gotcha IPA string comparisons may fail due to Unicode normalization (composed vs decomposed characters). Normalize strings with `unicodedata.normalize('NFC', s)` before comparison. ↓
fix Normalize both strings with `unicodedata.normalize('NFC', ...)` before comparing.
Imports
- IPA wrong
from gruut.ipa import IPAcorrectfrom gruut_ipa import IPA
Quickstart
from gruut_ipa import IPA
ipa = IPA('ˈsɝˌvɛɪ')
print(ipa) # 'ˈsɝˌvɛɪ'
print(ipa.stripped()) # 'sɝvɛɪ'
print(ipa.phonemes) # ['ˈ', 's', 'ɝ', ',', 'v', 'ɛ', 'ɪ']