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.4.0"       # Rule-based languages (ES, FR, PT, SV)
pip install "piper-plus-g2p[ja,en]==0.4.0" # Japanese + English
pip install "piper-plus-g2p[all]==0.4.0"   # 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.4.0

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.4.0
File Size Uploaded Provenance Actions
piper_plus_g2p-0.4.0.tar.gz 3.3 MB With provenance Details for piper_plus_g2p-0.4.0.tar.gz

Built distribution (wheel)

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

Total release size: 6.6 MB

Release files / piper_plus_g2p-0.4.0.tar.gz

Download URL piper_plus_g2p-0.4.0.tar.gz
Size 3.3 MB
Tags Source
SHA-256 checksum
How to use checksums
afbb484f2e2254a66b23675d7218b7d43380b0c03a80185946d9dc1841625853
BLAKE2b-256 checksum
How to use checksums
04c11c6e01adc0030ccc54dde4c0b9e5554b67dd1ffead83efa18bd535c3d7af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 13, 2026.

Transparency log

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

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

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 Nov 13, 2026.

Transparency log

Security for piper-plus-g2p 0.4.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for piper_plus_g2p-0.4.0.tar.gz

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 Nov 13, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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