misaki
A multilingual grapheme-to-phoneme engine built for the Kokoro text-to-speech models
Repository Health
Technical Analysis
misaki is a grapheme-to-phoneme (G2P) engine designed specifically for the Kokoro family of TTS models, converting raw input text into the phoneme sequences those models expect. It bundles per-language tokenizer/G2P pipelines behind optional extras — English (with an espeak fallback for out-of-dictionary words), Japanese (via pyopenjtalk with full unidic for pitch accent), Korean, Chinese, Vietnamese, and Hebrew — each wrapping established third-party tokenization and phonemization tools rather than reimplementing linguistics from scratch.
Each language’s G2P pass returns both the phoneme string and per-token metadata, and the English pipeline in particular supports an optional transformer-based POS/stress model as well as an espeak-ng fallback for words not covered by its dictionary, giving callers a tunable accuracy/dependency tradeoff.
What You Get
- Per-language G2P classes for English, Japanese, Korean, Chinese, Vietnamese, and Hebrew, each installable as an optional extra
- An espeak-ng fallback path for English out-of-dictionary words, avoiding silent mispronunciation
- Second-generation Japanese tokenization via pyopenjtalk with full unidic, including pitch-accent marks
- Optional transformer-based (spaCy-curated-transformers) English tokenization for improved POS-aware phonemization
- Structured per-token output alongside the phoneme string for downstream alignment or debugging
- A hosted Hugging Face Space demo for trying phonemization without a local install
Common Use Cases
- Preprocessing text into phonemes as the input stage of a Kokoro-based TTS pipeline
- Building multilingual voice applications that need consistent G2P across English, Japanese, Korean, and Chinese
- Handling out-of-dictionary or informal English text robustly via the espeak fallback
- Research or prototyping around phoneme-level text representations for speech synthesis
Under The Hood
Architecture — The misaki/ package is organized as one module per language (en.py, plus dedicated subpackages like g2pkc for Korean and zh_normalization for Chinese text normalization), each defining a G2P class that composes a tokenizer, a phoneme dictionary/model lookup, and an optional fallback (e.g. espeak.EspeakFallback for English). Rather than implementing tokenization and phonemization from scratch, each language module is a thin orchestration layer over established third-party tools — spaCy for English tokenization, pyopenjtalk/unidic for Japanese, jieba/pypinyin for Chinese — unified behind a consistent G2P(text) -> (phonemes, tokens) call signature. Tech Stack — Python packaged with Hatchling; core dependencies are minimal (addict, regex) with heavy per-language extras declared in pyproject.toml (spacy, torch, transformers for English; fugashi, pyopenjtalk, unidic for Japanese; jieba, pypinyin, cn2an for Chinese), so installs stay light unless a specific language is requested. Code Quality — The repository ships an examples/ directory demonstrating usage per language rather than a formal automated test suite in the traditional sense; given the heavy reliance on external linguistic tools (espeak, unidic, mecab), most correctness risk lives in those upstream dependencies rather than misaki’s own glue code. GitHub activity data shows the project has had a recent lull in commits, consistent with a research-driven project reaching a stable release cadence. API Design — The from misaki import en; g2p = en.G2P(...) pattern is consistent across languages and requires almost no boilerplate to get a first phoneme string, though understanding which optional extras (pip install misaki[en]) are needed per language, and configuring fallback behavior correctly, requires reading the README rather than being self-evident from the API alone.