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
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.
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.

Parse an IPA string and access its components.

from gruut_ipa import IPA

ipa = IPA('ˈsɝˌvɛɪ')
print(ipa)  # 'ˈsɝˌvɛɪ'
print(ipa.stripped())  # 'sɝvɛɪ'
print(ipa.phonemes)  # ['ˈ', 's', 'ɝ', ',', 'v', 'ɛ', 'ɪ']