Skip to main content

PyPI - Version PyPI - Python Version PyPI - Downloads codecov

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

  • text phoneme voices with no eSpeak dependency.
  • espeak voices through espeakng-runtime, which provides native eSpeak NG access and CLI fallback while PiperG2P retains Piper-specific phoneme composition.
  • 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 PiperG2P normally. It depends on espeakng-runtime, which owns eSpeak discovery and execution. Text voices do not invoke eSpeak. For a bundled loader and data support, install piperg2p[espeak-direct].

PIPERG2P_ESPEAK_EXECUTABLE, PIPERG2P_ESPEAK_LIBRARY, and PIPERG2P_ESPEAK_DATA remain supported compatibility variables. Explicit Piper constructor arguments take precedence over these variables, which take precedence over ESPEAKNG_RUNTIME_* variables and runtime discovery.

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.

Release files for piperg2p 0.1.3

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

Source distribution (sdist)

Source distribution for piperg2p 0.1.3
File Size Uploaded
piperg2p-0.1.3.tar.gz 264.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for piperg2p 0.1.3
File Interpreter ABI Platform
piperg2p-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 315.0 kB

Release files / piperg2p-0.1.3.tar.gz

Download URL piperg2p-0.1.3.tar.gz
Size 264.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e8f92c56e906c95ed8c7856df6da786111d68f7982d92c851ac677e6b1ffbcd4
BLAKE2b-256 checksum
How to use checksums
276537054183ce093e7ce6431bd4aeb3e088fffa21a41268b2aac7961bfd6dc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / piperg2p-0.1.3-py3-none-any.whl

Download URL piperg2p-0.1.3-py3-none-any.whl
Size 50.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
87fd89b458a83df3853b388dc5fc587d6819b4640a07ebdc7cf6063d5ebcacec
BLAKE2b-256 checksum
How to use checksums
bbbb16756a01cc2637cdaf2015810415e2631409319d5cf78d6ca1d504011fd1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

0.1.5

2 release files

0.1.4

2 release files

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

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