Skip to main content

piper-plus-g2p

Multilingual G2P (Grapheme-to-Phoneme) for TTS. eSpeak-ng free. MIT licensed. 8 languages.

Standalone package — piper-plus TTS エンジンなしで G2P 単体として利用可能です。任意の TTS エンジンと組み合わせて使えます。

Why piper-plus-g2p?

  • 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

Comparison

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

Installation

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 languages

Note: The ja extra requires pyopenjtalk-plus, which provides pre-built wheels for Linux, macOS, and Windows. See pyopenjtalk-plus for platform details.

Quick Start

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"]

Supported Languages

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

Advanced Usage

Multilingual (Composite Language Code)

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.

ZH-EN Code-Switching (English Inside Chinese Context)

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 backend

Custom 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")

PiperEncoder

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 Model Compatibility

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 inference

Use strict=True to raise errors on unknown tokens instead of silently skipping them:

encoder = PiperEncoder(config["phoneme_id_map"], strict=True)

Cross-Platform Consistency

piper-plus-g2p is also available as:

  • Rust crate: piper-plus-g2p on crates.io
  • Go module: github.com/ayutaz/piper-plus/src/go/phonemize
  • npm package: @piper-plus/g2p for browser/WASM

All three implementations share the same PUA mapping table and are validated against a common test fixture.

Requirements

License

MIT

Metadata

Release files for piper-plus-g2p 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for piper-plus-g2p 0.3.1
File Size Uploaded
piper_plus_g2p-0.3.1.tar.gz 3.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for piper-plus-g2p 0.3.1
File Interpreter ABI Platform
piper_plus_g2p-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 6.5 MB

Release files / piper_plus_g2p-0.3.1.tar.gz

Download URL piper_plus_g2p-0.3.1.tar.gz
Size 3.3 MB
Tags Source
SHA-256 checksum
How to use checksums
61b13a33ae25ab57aa9e7197847bdff787a4f490e29b9867336bf0e0700d54e6
BLAKE2b-256 checksum
How to use checksums
fb5a416da1a0e8f10d5860b2ac1c36a6b404be3c8d0c0340602de2d30b44d5c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release files / piper_plus_g2p-0.3.1-py3-none-any.whl

Download URL piper_plus_g2p-0.3.1-py3-none-any.whl
Size 3.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
4139f2d7dd2e879273e2d433deac1f8ae9066edcf42b46e9edda3136ae0c70d6
BLAKE2b-256 checksum
How to use checksums
122d2fa7156d19e8cc74debadae90929bad7767e2f7b211d860279d2b9ab3aab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page