kitteng2p
Independent phoneme and token-ID frontend targeting the public KittenTTS v0.8 text-cleaner contract.
kitteng2p turns prepared, speakable text into eSpeak phonemes, Kitten-prepared
phoneme text, character IDs, and model framing (0, *ids, 10, 0). It does not
synthesize audio, load ONNX models, download voices, or perform written-to-spoken
semantic normalization. Callers prepare dates, currencies, units, URLs, and
abbreviations before phonemization.
The package has a flat layout and uses setuptools-scm for dynamic versioning.
Installation
Install kitteng2p and make a system eSpeak or eSpeak NG runtime available to
espeakng-runtime:
python -m pip install kitteng2p
Where supported, install the optional bundled runtime assets instead:
python -m pip install "kitteng2p[bundled]"
The bundled extra provisions eSpeak runtime assets where supported. It does
not install KittenTTS, a TTS model, or audio dependencies.
Quick start
from kitteng2p import KittenG2P
with KittenG2P() as g2p:
result = g2p.phonemize_prepared("Hello, world.")
print(result.phonemes)
print(result.token_ids)
print(result.dropped_symbols)
The result's token_ids already include model framing. The convenience
functions phonemes() and phoneme_ids() create and close a temporary frontend.
G2Lex sources and occurrence context
The default configuration remains eSpeak-only. To opt in to named Lexphon catalog entries or local IPA .g2lex files, configure the source stack explicitly. Local files are evaluated in the order supplied, followed by named selectors in the order supplied; source misses fall through to later sources and then eSpeak. Selected IPA values are checked against Kitten's codec and unsupported symbols fail instead of being silently dropped.
from kitteng2p import G2LexFileRef, KittenG2P, KittenG2PConfig, LinguisticToken
text = "A minute crack appeared."
minute_start = text.index("minute")
config = KittenG2PConfig(
g2lex_files=(G2LexFileRef("./book-pronunciations.g2lex"),),
lexicons=("lexhint",),
lexicon_data_policy="installed-only",
)
tokens = (
LinguisticToken(minute_start, minute_start + len("minute"), "minute", pos="NOUN", tag="NN"),
)
with KittenG2P(config) as g2p:
result = g2p.phonemize_prepared(text, tokens=tokens)
print(result.phonemes)
print(result.pronunciation_trace)
Request-local PronunciationOverride spans have highest precedence. Tokens and override offsets are half-open character spans into the original prepared text. Context rules use the supplied tags and nearby sentence text without downloading an NLP model. PhonemizeResult.pronunciation_trace records each occurrence's source, selector, and decision reason.
discover_lexicons(language="en-us") returns catalog metadata and installed state without installing assets; only a selected named source may be provisioned under the auto policy. inspect_g2lex_file(path) reports canonical path, content and logical hashes, entry count, locale, encoding, and Kitten compatibility.
Command line
kitteng2p "Hello, world."
kitteng2p --language en-gb "Hello, world."
kitteng2p --espeak-mode cli "Hello, world."
The command prints one JSON object with the original text, prepared phonemes, framed token IDs, and any dropped symbols.
Kitten v0.8 compatibility target
kitteng2p reproduces the public KittenTTS v0.8 text-cleaner symbol inventory
and model-ID framing:
- the same pad, punctuation, ASCII-letter, and IPA symbol inventory;
- duplicate symbols use the last dictionary index, matching upstream construction;
- symbols outside the inventory are dropped;
- model IDs are framed as
(0, *ids, 10, 0).
This is a codec-level compatibility claim. The released KittenTTS 0.8.1 path
uses phonemizer around eSpeak, while kitteng2p uses espeakng-runtime.
Exact sentence-level ID parity has not been established across a representative
corpus. Do not interpret codec compatibility as end-to-end phonemizer parity.
See the compatibility policy.
Documentation
- Installation
- Quick start
- API reference
- Codec contract
- eSpeak backend
- Command line
- Compatibility policy
- Architecture
- Changelog
- Runnable examples
Dynamic versioning
Package versions are derived from Git tags through setuptools-scm. Source
archives without Git metadata use the configured 0.1.dev0 fallback. Create a
release tag only after the release checklist and artifact gates have passed.
At runtime, kitteng2p.__version__ reports the installed distribution version.
Development
python -m pip install -e ".[dev,docs]"
python -m pytest
python -m ruff check kitteng2p tests examples
python -m mypy kitteng2p
python -m compileall -q kitteng2p tests tools examples
python docs/make.py html
python -m build --sdist --wheel
Metadata
Release files for kitteng2p 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kitteng2p-0.1.2.tar.gz | 52.5 kB | Without provenance | Details for kitteng2p-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kitteng2p-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for kitteng2p-0.1.2-py3-none-any.whl |
Total release size: 81.6 kB
Release files / kitteng2p-0.1.2.tar.gz
| Download URL | kitteng2p-0.1.2.tar.gz |
|---|---|
| Size | 52.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ee0f37e0da7370ed4427393b977940d2a88a8252f63fad03118b463ff4a61871
|
|
BLAKE2b-256 checksum How to use checksums |
9b7d44a22956459b9b00537c35ce0f2a44b3be268529db1c505f4c79b9689399
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Release files / kitteng2p-0.1.2-py3-none-any.whl
| Download URL | kitteng2p-0.1.2-py3-none-any.whl |
|---|---|
| Size | 29.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3da6b23e454b92bbd2edade75b2969bdfa0932ff963db3b10aa6b66f79e75463
|
|
BLAKE2b-256 checksum How to use checksums |
75e43d3965ec22e287c3657bce2283845c14d9bedd9257d94bac19c1493b8a52
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Security for kitteng2p 0.1.2
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.