Logo Lanfrica

AfriSpeech/africa-g2p

Domain:

natural language processing

Record type:

softwaretools
Creator:
Afr
Host:
Rule-based grapheme-to-phoneme (G2P) for 400+ African languages — convert text to native-orthography phonemes (great for TTS/ASR training) or IPA, with romanisation for non-Latin scripts. Data from Omniglot & Alphabets of Africa. # africa-g2p Segment written text in **400+ African languages** into phonemes — for text-to-speech, ASR, pronunciation lexicons, and linguistic tooling. Many languages support **multiple scripts** (e.g. Vai syllabary and Latin), and non-Latin scripts can be **transliterated to Latin** too. By default the output is in each language's **native writing system** (the actual alphabet, with multigraphs like `ny`, `kp`, `gb` kept as single units) — which trains TTS/ASR models better than IPA. IPA transcription is available with one option. ```python from africa_g2p import AfricaPipeline AfricaPipeline(lang="twi").run("Akwaaba", sep=" ") # 'a kw a a b a' AfricaPipeline(lang="twi", output="ipa").run("Akwaaba", sep=" ") # 'a kʷ a a b a' ``` ## Install ```bash pip install africa-g2p ``` From source: ```bash git clone github.com cd africa-g2p pip install -e . ``` Pure Python (3.9+), no runtime dependencies. English is the one exception — see below. ## English African speech is full of English, so English is supported too, but **not** through the rule tables. It routes to espeak-ng: ```bash pip install "africa-g2p[english]" apt install espeak-ng # or: brew install espeak-ng ``` ```python from africa_g2p import AfricaPipeline AfricaPipeline(lang="eng").run("through though tough thought", sep=" ") # 'θɹuː ðoʊ tʌf θɔːt' ``` **Why it cannot use the tables.** Greedy longest-match over a grapheme table is the right algorithm for the shallow orthographies in this package, and the wrong one for English: it maps *through*, *though*, *tough* and *thought* to a single identical string. `ough` alone has six readings, decided by etymology and morphology rather than by adjacent letters. Output is normalised to the same IPA conventions as the other 400 languages, so English phonemes share one inventory with them — no per-language tagging needed. Every symbol espeak emits already occurs somewhere in the rule tables, an …