piperg2p
piperg2p is an independent, voice-config-driven Piper-compatible frontend. It produces phoneme sequences and model IDs from Piper ONNX voice configurations. It does not synthesize audio, require Piper, or include Piper source or model data.
Delivered scope
textphoneme voices with no eSpeak dependency.espeakvoices through a native eSpeak NG public API binding or an explicit CLI fallback.- Unicode NFD normalization and voice-specific ID maps.
- Sentence-grouped results and raw
[[ ... ]]phoneme blocks in eSpeak mode. - Immutable diagnostics, typed configuration, errors, and missing-phoneme reporting.
The native clause API is labeled exact only when it is available. The CLI path is always labeled best-effort. This release supports the named Piper Python text and ordinary espeak profile only. Pinyin, Hebrew, Japanese, and Thai are recognized configuration values but unavailable. Arabic eSpeak voices are rejected until Piper-compatible preprocessing is implemented.
Install
pip install .
PiperG2P consumes prepared, speakable text. It does not verbalize numbers, abbreviations, units, currencies, dates, times, URLs, versions, or other written semantics. Prepare those forms in the calling application, then pass the result to phonemize_prepared().
PiperG2P has no runtime dependency on Spokenform or Numeralform. Installing either package does not change core PiperG2P behavior.
This boundary does not change eSpeak compatibility: PiperG2P passes prepared text to the selected backend, and backend-specific pronunciation behavior remains unchanged.
Install eSpeak NG separately for eSpeak voices. Text voices need no optional runtime package.
Semantic preparation composition
Use a separate preparation package only when written semantics need expansion:
from spokenform import prepare_for_piperg2p
from piperg2p import phonemize_prepared
prepared = prepare_for_piperg2p(
"Pay $12.50 for 2 kg.",
language="en",
).spoken_text
result = phonemize_prepared(
prepared,
language="en-us",
config="voice.onnx.json",
)
print(result.phonemes)
print(result.token_ids)
Install Spokenform separately. It is not required for PiperG2P core installation or core tests.
Usage
from piperg2p import PiperFrontend
frontend = PiperFrontend.from_config("voice.onnx.json")
result = frontend.phonemize("Hello, world.")
for sentence in result.sentences:
print(sentence.phoneme_string)
print(sentence.ids)
print(sentence.missing_phonemes)
The configured phoneme_id_map is authoritative. result.ids is a convenience flattening of sentence IDs. Model inference should normally consume each sentence.ids separately.
Lexicon-first mode
Lexicon support is an opt-in overlay on the existing eSpeak frontend. Install piperg2p[lexphon] for managed Lexphon identifiers or piperg2p[g2lex] for explicit local .g2lex files. Raw [[...]] blocks have precedence, lexicon misses use PiperG2P's eSpeak backend, and no dictionary downloads occur implicitly. See docs/lexicons.md.
Use *:espeak assets for generic IPA pronunciation overrides. Use *:espeak-piper assets for Piper raw phoneme behavior with phoneme_encoding="espeak-ipa3". Lexphon installs and verifies data externally, while PiperG2P owns interpretation, precedence, and voice-map ID encoding.
Compatibility
Compatibility is measured against pinned reference profiles, not a moving upstream branch. See docs/compatibility.md, docs/espeak.md, and docs/provenance.md.
Independence
The runtime package has no Piper dependency, does not import Piper, and does not bundle Piper GPL assets. Reference corpus metadata is development evidence only.
Sibling-style API
The high-level API keeps Piper voice configuration explicit while matching the shared development vocabulary used by sibling frontends:
from piperg2p import phonemize_prepared
result = phonemize_prepared(
"Hello world", language="en-us", config="voice.onnx.json"
)
print(result.phonemes)
print(result.token_ids)
Use get_g2p(language, config=...) for reuse. tokenize, OverrideSpan, TokenAnnotation, marker helpers, bounded cache_info, and ids_to_phonemes are also exported. The API never downloads models or lexicons. See examples/README.md for the twelve executable examples.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file piperg2p-0.1.1.tar.gz.
File metadata
- Download URL: piperg2p-0.1.1.tar.gz
- Upload date:
- Size: 222.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3300a78873023c637c92cc81d7ef5f15fee19fdd8302cd63b78a39a3ebb960d
|
|
| MD5 |
f411f2c28a9f315eecc37e8bca5e669d
|
|
| BLAKE2b-256 |
95bd02689df72e409a36dca359777d7d14d4a5747a6defd470a53502ee0b9d15
|
File details
Details for the file piperg2p-0.1.1-py3-none-any.whl.
File metadata
- Download URL: piperg2p-0.1.1-py3-none-any.whl
- Upload date:
- Size: 49.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e347394df3156372530ed3b11821238db8e68725e542723b7cc1cf91491af292
|
|
| MD5 |
f4e9043a816dfec278dea88752262103
|
|
| BLAKE2b-256 |
7b39789e30af41122aa093a30d3b2adca956723827ce9e650618a587245d13e2
|