Multilingual G2P (Grapheme-to-Phoneme) for TTS. eSpeak-ng free. MIT licensed. 8 languages.
Standalone package — piper-plus TTS エンジンなしで G2P 単体として利用可能です。任意の TTS エンジンと組み合わせて使えます。
- MIT licensed -- no eSpeak-ng (GPL) dependency in your TTS pipeline
- 8 languages -- JA, EN, ZH, KO, ES, FR, PT, SV with consistent IPA output
- IPA-first design -- returns pure IPA token sequences, ready for any TTS model
| piper-plus-g2p | phonemizer | gruut | Misaki | |
|---|---|---|---|---|
| License | MIT | GPL (eSpeak-ng) | MIT | Apache-2.0 |
| Languages | 8 | 100+ | 20+ | EN only |
| eSpeak-ng required | No | Yes | No | No |
| IPA output | Yes | Yes | Yes | Yes |
pip install "piper-plus-g2p==0.3.1" # Rule-based languages (ES, FR, PT, SV)
pip install "piper-plus-g2p[ja,en]==0.3.1" # Japanese + English
pip install "piper-plus-g2p[all]==0.3.1" # All 8 languagesNote: The
jaextra requirespyopenjtalk-plus, which provides pre-built wheels for Linux, macOS, and Windows. See pyopenjtalk-plus for platform details.
from piper_plus_g2p import get_phonemizer
ja = get_phonemizer("ja")
ja.phonemize("こんにちは")
# -> ["k", "o", "[", "N_n", "n", "i", "ch", "i", "w", "a"]
en = get_phonemizer("en")
en.phonemize("Hello world")
# -> ["h", "ə", "l", "ˈ", "o", "ʊ", " ", "w", "ˈ", "ɜ", "ː", "l", "d"]| Language | Code | Extra | Backend | Notes |
|---|---|---|---|---|
| Japanese | ja |
piper-plus-g2p[ja] |
pyopenjtalk-plus | Context-dependent N variants, prosody info |
| English | en |
piper-plus-g2p[en] |
Bundled g2p-en 2.1.0 source |
CMU-dict + neural fallback; Apache-2.0 / MIT notices included |
| Chinese | zh |
piper-plus-g2p[zh] |
pypinyin | Pinyin-to-IPA, ZH-EN code-switching (loanword pinyinisation) |
| Korean | ko |
piper-plus-g2p[ko] |
g2pk2 | Optional dependency |
| Spanish | es |
-- | Rule-based | No external dependency |
| French | fr |
-- | Rule-based | No external dependency |
| Portuguese | pt |
-- | Rule-based | No external dependency |
| Swedish | sv |
-- | Rule-based | No external dependency |
Pass a hyphen-joined code like "ja-en-zh" to get_phonemizer to
automatically create a MultilingualPhonemizer. Language detection is
Unicode-based, so mixed-script text is handled without explicit tagging.
from piper_plus_g2p import get_phonemizer
multi = get_phonemizer("ja-en-zh")
tokens = multi.phonemize("こんにちは Hello 你好")Version 0.3.1 bundles the reviewed English backend under a private
namespace; the en extra installs NumPy, NLTK, joblib and inflect, without
installing the external g2p-en distribution or its unused GPL Distance
dependency. The vendored namespace is an implementation detail, not a public
import path. The already published piper-plus-g2p==0.3.0 wheel still has the
old dependency metadata. See the
migration guide and
third-party notices.
When an English token (acronym, brand, technical term) appears next
to a Chinese segment, MultilingualPhonemizer routes it through
ChinesePhonemizer.phonemize_embedded_english so it is rendered as
Mandarin pinyin instead of US English -- matching how Chinese
speakers naturally pronounce inserted English words.
from piper_plus_g2p import get_phonemizer
multi = get_phonemizer("zh-en")
multi.phonemize("请打开 GPS") # GPS -> ji4-pi4-ai1-si4 (pinyin)
multi.phonemize("我喜欢用 Python 写代码") # Python -> pai4-sen1
multi.phonemize("Hello world") # No zh context -> bundled English backendCustom overrides (acronym/loanword/letter_fallback) are loaded from a
JSON file shaped like the bundled data/zh_en_loanword.json:
from piper_plus_g2p.chinese import ChinesePhonemizer
zh = ChinesePhonemizer(zh_en_loanword_dict_paths="my_overrides.json")
zh.phonemize_embedded_english("MYORG")Converts IPA token lists into integer phoneme_ids for Piper ONNX models.
from piper_plus_g2p.encode import PiperEncoder, get_phoneme_id_map
id_map = get_phoneme_id_map("ja")
encoder = PiperEncoder(id_map)
phoneme_ids = encoder.encode(["k", "o", "[", "N_n", "n", "i", "ch", "i", "w", "a"])piper-plus-g2p produces phoneme tokens directly compatible with
Piper TTS ONNX models. Use
PiperEncoder with the model's phoneme_id_map from config.json:
import json
from piper_plus_g2p import get_phonemizer
from piper_plus_g2p.encode import PiperEncoder
with open("model/config.json") as f:
config = json.load(f)
encoder = PiperEncoder(config["phoneme_id_map"])
phonemizer = get_phonemizer("ja")
tokens = phonemizer.phonemize("こんにちは")
phoneme_ids = encoder.encode(tokens)
# -> ready for ONNX inferenceUse strict=True to raise errors on unknown tokens instead of silently
skipping them:
encoder = PiperEncoder(config["phoneme_id_map"], strict=True)piper-plus-g2p is also available as:
- Rust crate:
piper-plus-g2pon crates.io - Go module:
github.com/ayutaz/piper-plus/src/go/phonemize - npm package:
@piper-plus/g2pfor browser/WASM
All three implementations share the same PUA mapping table and are validated against a common test fixture.
- Python >= 3.11
- Language backends are installed via extras (see Supported Languages)
MIT