Skip to main content

speechready (Python)

Prepare text for text-to-speech. See the repository README for the project overview.

pip install speechready

Python 3.10 or newer; the only dependency is PyYAML. Try it without installing at berkerbatur.github.io/speechready/play.

Usage

from speechready import prepare

result = prepare(
    "**Step 1:** run `npm install`. [pause 1s] Then read https://example.com/docs.",
    provider="elevenlabs",
    model="eleven_multilingual_v2",
    locale="en-US",
)

result.text     # 'Step 1: run npm install. <break time="1s" /> Then read example.com.'
result.chunks   # the same text split under the model's request limit
for change in result.changes:
    print(change.rule, repr(change.before), "->", repr(change.after))

The verbalize stage rewrites only what models misread: phone numbers and long digit strings (digit by digit), numeric dates in the locale's order, 24-hour times, currency amounts, percent and unit abbreviations, small fractions, number ranges, years in context, decades, ordinals, and identifiers such as AB12X9. Ordinary numbers, decimals and pronounceable names like COVID-19 are left alone.

Turkish (locale="tr-TR") adds what foreign models get wrong in Turkish: suffixes on numerals and abbreviations are joined to the spoken word with vowel harmony and buffer consonants (3'te → üçte, 1990'da → bin dokuz yüz doksanda, 100 TL'ye → yüz liraya, 1/4'ü → çeyreği), %50 → yüzde elli, dotted thousands 1.250 → bin iki yüz elli, decimal commas 3,14 → üç virgül on dört, 3. madde → üçüncü madde, dates 27.10.2026 → yirmi yedi Ekim iki bin yirmi altı, and abbreviations such as vb., Dr., Üniv., Cad. read in full.

Inline intents in the input: [pause 500ms], [pause 1.5s], [spell AB12], [em really]. An SSML <break time="..."/> you already have is read as a pause intent and re-rendered for the target.

provider and model pick a profile from spec/profiles; with neither, the plain profile renders pauses as punctuation and returns one chunk. Pass profile=load_profile("azure-neural") to pick one directly and limit= to override the request limit.

Everything a caller may want to decide differently is an Options field, and the defaults are what the evaluation ran with:

from speechready import Options, prepare

prepare(text, provider="openai", options=Options(
    code_blocks="keep",        # drop (default) | keep: read fenced code aloud | mention: one sentence stands in for it
    code_block_mention=None,   # what `mention` says; None = "See the code block." / "Kod bloğuna bakın."
    tables="rows",             # rows (default, each row a comma list) | drop
    urls="domain",             # domain (default) | drop | keep
    emails="keep",             # keep (default) | drop
    emoji="drop",              # drop (default) | keep
    emphasis="strip",          # strip (default) | intent: **bold** becomes an emphasis intent
    list_numbers="keep",       # keep (default, "1. Open the app") | drop
    fractions="spoken",        # spoken (default: "one half", "yarım") | division ("one over two", "bir bölü iki")
    foreign_acronyms=True,     # Turkish: npm, css, sql read with English letter names (en pi em)
    terminal_punctuation=".",  # added to a block that ends without one
))

Phone numbers follow each language's habit: English reads digit by digit with a pause between groups, Turkish reads each group as a number (0532 123 45 67 → sıfır beş yüz otuz iki, yüz yirmi üç, kırk beş, altmış yedi).

Pronunciation lexicon, one file for every vendor:

from speechready import Lexicon, prepare, load_profile

lex = Lexicon.load("examples/lexicon.en.yaml")      # entries with ipa, say or spell
prepare("Restart Nginx.", provider="azure", lexicon=lex).text
# 'Restart <phoneme alphabet="ipa" ph="ˈɛndʒɪnˈɛks">Nginx</phoneme>.'
prepare("Restart Nginx.", provider="openai", lexicon=lex).text
# 'Restart engine X.'            (no phoneme tags on OpenAI, so the respelling is used)

lex.to_pls()                                         # PLS XML for ElevenLabs, Azure and Polly uploads
lex.to_google_json()                                 # Google Cloud TTS custom pronunciations
lex.export_for(load_profile("elevenlabs-v2"))        # the right one for a profile, or None

An inline [ipa Nginx ˈɛndʒɪnˈɛks] tag does the same for one word without a file.

Voice agents

Two frameworks take a text transform between the LLM and the TTS. Both hooks are plain callables, so they need nothing beyond speechready:

# LiveKit Agents 1.8+: sentences are released as they are confirmed in the token stream
from speechready.integrations.livekit import text_transform
session = AgentSession(..., tts_text_transforms=[text_transform(provider="elevenlabs", model="eleven_turbo_v2_5")])

# Pipecat 1.14+: runs on each sentence the TTS service aggregates; register it on the TTS, not on LLMTextProcessor
from speechready.integrations.pipecat import text_transform
tts = ElevenLabsTTSService(..., text_transforms=[("*", text_transform(provider="elevenlabs", model="eleven_turbo_v2_5"))])

Both take the arguments of prepare (provider, model, locale, options, lexicon). Fenced code blocks that arrive over several tokens or pieces are held until the closing fence and handled as one block, so code_blocks="drop" and "mention" work in streams too. Any other framework can do the same with Segmenter:

from speechready import Segmenter

seg = Segmenter(locale="en-US")
for token in llm_stream:
    for sentence in seg.push(token):
        tts.say(prepare(sentence, provider="openai").text)
for sentence in seg.flush():
    tts.say(prepare(sentence, provider="openai").text)

Development

cd python
python -m pip install -e ".[dev]"
pytest

Tests run every fixture in ../spec/fixtures, which the JavaScript package must pass as well.

Metadata

Release files for speechready 0.2.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 speechready 0.2.0
File Size Uploaded Provenance Actions
speechready-0.2.0.tar.gz 35.5 kB With provenance Details for speechready-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 83.1 kB

Release files / speechready-0.2.0.tar.gz

Download URL speechready-0.2.0.tar.gz
Size 35.5 kB
Tags Source
SHA-256 checksum
How to use checksums
623b9532af71abe380c2d2ef55311e3a071b889e91d74418b67c6d43bc06b042
BLAKE2b-256 checksum
How to use checksums
03ac4df4ba9dac377f92e3ade6f7aefda4516220efb2a17673e32ce72bd82718
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 2, 2026.

Transparency log

Release files / speechready-0.2.0-py3-none-any.whl

Download URL speechready-0.2.0-py3-none-any.whl
Size 47.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bd4b4be5169aafd645b5403b4e7505376814f467a240d1ac783f138497c26963
BLAKE2b-256 checksum
How to use checksums
bdfd08835ef0e9795b01d3e24a9d75c7e4c340a33d644984044a71ad1983bae1
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 2, 2026.

Transparency log

Security for speechready 0.2.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 speechready-0.2.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 2, 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