Language support
KokoroG2P provides language-specific phonological frontends over a common prepared-text
pipeline. Select the language explicitly with phonemize_prepared() or get_g2p().
Written-to-spoken semantic preparation is outside every frontend.
Common contract
from kokorog2p import phonemize_prepared
result = phonemize_prepared("Bonjour le monde", language="fr")
All frontends preserve prepared input and expose token-level phonemes. Numbers,
quantities, dates, times, currencies, units, abbreviations, and URLs must be prepared by
the calling application. Language switching is also explicit: use OverrideSpan or
annotation language metadata for a known foreign span. No generic automatic detector is
included.
Native and dictionary frontends
Language |
Code |
Frontend |
|---|---|---|
English (US/GB) |
|
dictionary and rule-based |
German |
|
dictionary and rule-based |
French |
|
dictionary and rule-based |
Spanish |
|
rule-based |
Italian |
|
rule-based and lexicon |
Portuguese |
|
rule-based |
Czech |
|
rule-based |
Vietnamese |
|
native rule-based |
Swedish |
|
native rule-based |
Russian |
|
LexHint with eSpeak fallback |
Kazakh |
|
eSpeak adapter |
Hindi |
|
eSpeak-NG raw-IPA adapter |
Hebrew |
|
Phonikud adapter |
Arabic |
|
optional diacritizer adapter |
Chinese |
|
pypinyin/Zhuyin frontend |
Japanese |
|
pyopenjtalk or Cutlet |
Korean |
|
LexHint fast path plus g2pK |
Thai |
|
LexHint with native fallback |
Hindi accepts hi, hi-in, hi_IN, hin, and hindi, and uses the eSpeak-NG hi
voice as a lazy raw-IPA adapter for stock Kokoro v1.0. The frontend preserves Hindi
vowel length, nasalization, aspiration, retroflexion, and native vowel quality, then
validates the result against the model vocabulary. Hindi is prepared-text only, has no
bundled or downloaded runtime lexicon, and provides no automatic-routing evidence.
Install language-specific optional dependencies from the matching extras in
pyproject.toml, for example pip install "kokorog2p[ja]".
Backend and model controls
Use get_g2p() for backend-specific options such as backend, voice, or an
explicitly selected spaCy model. Semantic preparation options and abbreviation
registries are not accepted by the v0.9 API.
from kokorog2p import get_g2p
g2p = get_g2p("en-us", use_spacy=False)
print(g2p.phonemize("Hello world"))
Prepared-language composition
A cross-package pipeline may prepare text and then route the prepared result explicitly:
from spokenform import prepare_for_kokorog2p
from kokorog2p import phonemize_prepared
prepared = prepare_for_kokorog2p("Meeting at 2 kg", language="en").spoken_text
result = phonemize_prepared(prepared, language="en-us")
Spokenform is optional and is not imported by the core package.