Ghanaian English grapheme-to-phoneme: a 104k-word Ghanaian pronunciation lexicon, with espeak-ng behind it for out-of-vocabulary words.
# ghana-english-g2p
Ghanaian English text to IPA. A **104,623-word Ghanaian pronunciation lexicon** is
consulted first; `espeak-english` handles
whatever is left over.
```bash
pip install ghana-english-g2p
```
```python
from ghana_english_g2p import GhanaEnglishG2P
g2p = GhanaEnglishG2P()
g2p.ipa("Kwabena went to Achimota")
# 'kwabɪna wɛnt tuː atʃimota'
g2p.ipa("Kwabena went to Achimota", sep=" ")
# 'k w a b ɪ n a w ɛ n t t uː a tʃ i m o t a'
```
```bash
ghana-english-g2p "The Bank of Ghana raised the policy rate."
```
## Why this exists
espeak reads Ghanaian names as if they were English spelling. It does not fail loudly —
it returns a confident, fluent, wrong pronunciation:
| word | espeak alone | this lexicon |
|---|---|---|
| Kwabena | `k w e ɪ b n ə` | `k w a b ɪ n a` |
| Achimota | `ɐ tʃ ɪ m o ʊ ɾ ə` | `a tʃ i m o t a` |
| Okuapenhene | `o ʊ k j uː e ɪ p ə n h iː n` | `o k w a p ɛ n h ɛ n ɛ` |
| Bawumia | `b æ w uː m i ə` | `b a w u m i a` |
| Twumasi | `t w uː m ɑː s i` | `t w u m a s i` |
| Nyantakyi | `n a ɪ ɐ n t æ k ɪ i` | `ɲ a n t a tɕ i` |
Every one of these is a name a Ghanaian TTS or ASR system will meet on its first day.
The lexicon is what makes the output Ghanaian; espeak is the general-purpose fallback
behind it, not the other way round.
Rule-based conversion is not an option for this language pair, and that is measurable.
Running `ghana-g2p`'s Twi rules over 4,000 words
of this lexicon gives **7.6% exact-match and 50.1% phoneme error** — Ghanaian names come
out roughly right, English words are destroyed (`concerts` → `tʃ o n tʃ e ɾ t s`). Twi has
a shallow orthography and rules suit it; English does not, which is the reason
pronunciation dictionaries exist at all.
## One notation, both paths
espeak emits stress marks and a run-together transcription; the lexicon stores spaced
phones. Both go through the same segmenter, so **you cannot tell from the symbols which
path produced a word**:
```python
from ghana_english_g2p import segmen …