Tone-aware Yoruba grapheme-to-phoneme tool (IPA + ASCII) for speech research and MFA.
# 🇳🇬 Yoruba-G2P
### **Tone-Aware Yoruba Grapheme-to-Phoneme Toolkit (IPA + ASCII + MFA-Ready)**
**Yoruba-G2P** is a fully deterministic Python package for converting **Yorùbá text → phoneme sequences**, with correct **tones**, **nasal handling**, **affricates**, and **labial-velars**.
It outputs:
- ✔ **IPA dictionary**
- ✔ **ASCII-safe dictionary** (for MFA, ESPnet, Kaldi)
- ✔ **Phoneset file**
- ✔ **Lexicon statistics**
- ✔ **CLI + Python API**
- ✔ **Works on any Yoruba transcript**
- ✔ No ML training required → fully rule-based + Epitran-backed
---
## Installation
pip install epitran grapheme
This version uses Unicode grapheme-aware processing to ensure correct handling of Yorùbá underdot+tone-marked vowels.
### From PyPI (recommended)
```bash
pip install yoruba-g2p
````
### From GitHub
```bash
pip install git+
github.com
```
---
## 📣 Citation (for research)
## Citation
If you use this work, please cite:
```bibtex
@software{osakuade2026yoruba_g2p,
author = {Osakuade, Opeyemi},
title = {Yoruba-G2P: A tone-aware grapheme-to-phoneme converter for Yorùbá},
year = {2026},
version = {v0.2.4},
doi = {10.5281/zenodo.19721964},
url = {
github.com
}
```
---
## Quick Start (Python API)
```python
from yoruba_g2p import YorubaG2P
g2p = YorubaG2P()
print(g2p.yoruba_word_to_ipa_phones("ọ̀yọ́"))
print(g2p.ipa_phone_to_ascii("ọ̀mọ́"))
```
Output:
```
['ɔ_L', 'j', 'ɔ_H']
['O_L', 'm', 'O_H']
```
Another example:
```python
g2p.yoruba_word_to_ipa_phones("àwọn")
['a_L', 'w', 'ɔ_M', 'n']
```
---
## Command-line Interface (CLI)
Convert a sentence:
```bash
yoruba-g2p --ipa "àwọn ọmọ ń lọ"
yoruba-g2p --ascii "àwọn ọmọ ń lọ"
```
Build lexicons from `.lab` transcripts:
```bash
yoruba-g2p build-lexicon \
--lab-dir data/lab/train \
--out-dir dict/
```
You will get:
```
dict/ipa.dict
dict/ascii.dict
dict/phoneset.txt
dict/stats.json
```
All **MFA-ready**.
---
## What Yoruba-G2P Produces …