Logo Lanfrica

SpectreLabsAI/hausa-g2p

Domaine:

natural language processing

Type de record:

software
Créateur:
Spe
Hôte:
Rule-based Hausa Boko to segmental IPA. No ML, no dependencies. Reviewed and approved by a Kano native speaker. # hausa-g2p **Rule-based Hausa Boko → segmental IPA. No ML, no dependencies — a pure Python rule table and a keep-list text normaliser.** > ## ✅ Reviewed and approved by a Kano native speaker — 31 August 2026 > > Every rule in the table below was checked against recorded Kano Hausa by a > native-speaking reviewer, and the six open linguistic questions (f/p pair, > ts, gy/ky/ƙy, r, glottal identity, residuals) were all closed. This is not > a weekend script: the review protocol, the questions asked, and the > sign-off are in `LINGUIST_REVIEW.md`. ## Scope boundary — read this first **Output is segmental IPA only.** Hausa Boko orthography marks neither vowel length nor tone, and both are phonemic. No rule set can recover from orthography what orthography does not encode. This module deliberately does not guess: **TTS models learn suprasegmentals from paired audio, exactly as a literate Hausa speaker infers them from lexical knowledge when reading aloud.** A pronunciation lexicon marking length/tone is the obvious v2. ## Install & usage ```bash pip install hausa-g2p # or: copy hausa_g2p.py into your project ``` ```python from hausa_g2p import g2p, normalise g2p("Ƙofar ƙauye") # -> "kʼofaɾ kʼau̯je" g2p(text, return_unknowns=True) # -> (ipa, [unmapped chars]) normalise(text) # keep-list normaliser (apostrophes, quotes, invisibles) ``` CLI: `python hausa_g2p.py "ƙofar ’yan ƙasa"` ## The rule table Longest-match-first tokenisation (ƙw/ƙy before ƙ+w, digraphs before singles). | Class | Mapping | |---|---| | Ejectives | `ts → tsʼ`, `ƙ → kʼ`, `ƙw → kʷʼ`, `ƙy → cʼ` | | Implosives | `ɓ → ɓ`, `ɗ → ɗ` | | Labialised / palatalised | `kw → kʷ`, `gw → ɡʷ`, `ky → c`, `gy → ɟ`, `fy → fʲ` | | Plain consonants | `b c→tʃ d f g h j→dʒ k l m n p r→ɾ s sh→ʃ t w y→j z` | | Glottal | `'y → ʔj`, `ƴ → ʔj` (Niger orthography, same phoneme), bare `' → ʔ` | | Vowels | `a e i o u`, diphthongs `ai → ai̯`, `au → au̯` | | Punctuation | `. , ? ! : ;` pass t …