Skip to main content

ptts for Python

Python bindings for the Phonon Rust runtime.

To try it with uv, run:

uvx ptts --lang en "Hello world" -o out.wav

uvx handles the isolated Python environment and package dependencies. The first run downloads the default model, Phonon 31m, and caches it. --model accepts a local checkpoint directory or a Hugging Face repo as hf://owner/name, such as hf://gradium/phonon-40m-fr with --lang fr.

To use the Python API in your own environment, install the package:

pip install ptts

The wheel contains no model weights. Without a model argument, TTS downloads the default model on first use and caches it:

import ptts

tts = ptts.TTS(lang="en")
print(tts.voices)
tts.save("out.wav", "Hello world")

For a source install, use uv add /path/to/xn-ptts/ptts-pyo3 or pip install /path/to/xn-ptts/ptts-pyo3. Source builds need Rust installed; supported CPython wheels do not. See the development guide for repository build commands.

model, the first argument, names a local directory, a config.json, or a Hugging Face repo as "hf://owner/name" or "hf://owner/name@revision". Left out, it is ptts.DEFAULT_MODEL. Local paths download nothing. Gated repos, such as the Phonon 40m models, need their terms accepted on the model's Hugging Face page, then HF_TOKEN set or hf auth login. Rust examples, Python, and both servers use the shared checkpoint resolver. Every checkpoint supplies its own config.json and tokenizer.json. q8 prefers model.q8.gguf and q4k model.q4k.gguf; other formats prefer model.safetensors. Voices come from voices/ or embeddings/, plus default-voice.safetensors as default. Hub downloads use the revision after @ for all files. config= and revision= still work but are deprecated.

lang is required: en, fr, de, es or pt picks how numbers, symbols and abbreviations are spelled out, ar, hi, ko, pl, sv, fi, no, it, nl, ja, zh, da and tr spell out symbols only; none uses the text as written. ptts.normalize("It costs $5.", lang="en") shows that reading, "It costs 5 dollars.", without loading a model, and takes the same rewrites.

Speech and voices

Reuse tts across requests. Use synth for an array, save for a WAV, or stream for chunks as they are decoded:

voice = tts.voices[0]
pcm = tts.synth("Hello", voice=voice)  # 1-D float32 NumPy array
seconds = tts.save("out.wav", "Hello", voice=voice)
with tts.stream("A longer sentence.", voice=voice) as audio:
    for chunk in audio:
        print(chunk.shape)  # process each PCM chunk as it arrives

tts.sample_rate is the PCM sample rate; save writes a mono 16-bit WAV and returns its duration. Leaving the with block stops a stream early and waits for its workers to finish. Streaming keeps bounded audio and latent buffers: leaving a stream unread pauses generation once they fill, and consuming chunks lets it resume.

tts.voices lists the voices that were found, and tts.languages the languages the checkpoint's config says it was trained for. When no voice is given, the checkpoint's configured default is used, then default if present, then the first by name. Pass voice="name" to any speech method to select one. A name the checkpoint does not have is looked up in the voice catalog, by name in any case and with or without accents, or by its voice ID. Only that voice is downloaded, on first use, and then joins tts.voices. The catalog is ptts.DEFAULT_VOICE_CATALOG, gradium/phonon-voices, unless voice_catalog= names another: an hf://owner/name[@revision] repo, or a local voices.jsonl or a folder holding one. tts.add_voice("NAME", "voice.safetensors") adds a voice file, such as one from the Gradium Studio scripts. ptts.catalog_voices() lists it without loading a model, and ptts.catalog_voices(catalog) another one. To change the speaking rate, pass conditions={"duration_delta": -0.3} to speak faster, or a positive value to speak slower.

Command line

The package also provides the ptts command:

python -m ptts --lang en "Hello world" -o out.wav

--model loads another model, as TTS's first argument does. --voice selects a voice of the checkpoint or of --voice-catalog, and --list-voices prints the catalog's voices. Run with --help for the remaining options. The package ships type stubs and py.typed.

Wheels

Linux and Windows x86_64 wheels target x86-64-v3 (AVX2, FMA and F16C); older x86 CPUs need a source build. The macOS x86_64 wheel does not need AVX.

Released wheels are cp39-abi3, so one per platform covers every CPython from 3.9 on, and a new CPython release needs no new wheel. Free-threaded CPython and PyPy cannot load an abi3 extension, so those two install from the sdist and compile the Rust runtime, which needs a Rust toolchain and takes a few minutes.

License

MIT or Apache-2.0, at your option. The model weights are not part of the package and come with their own licenses: Phonon 31m is under Apache 2.0, and Phonon 40m and Phonon 40m multilingual are under CC BY-NC 4.0. See each model's page on Hugging Face.

Metadata

Release files for ptts 0.7.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 ptts 0.7.0
File Size Uploaded Provenance Actions
ptts-0.7.0.tar.gz 325.5 kB Without provenance Details for ptts-0.7.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for ptts 0.7.0
File Actions
ptts-0.7.0-cp39-abi3-win_arm64.whl CPython 3.9 abi3 Windows ARM64 Details for ptts-0.7.0-cp39-abi3-win_arm64.whl
ptts-0.7.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for ptts-0.7.0-cp39-abi3-win_amd64.whl
ptts-0.7.0-cp39-abi3-musllinux_1_2_x86_64.whl CPython 3.9 abi3 Linux musl 1.2+ x86-64 Details for ptts-0.7.0-cp39-abi3-musllinux_1_2_x86_64.whl
ptts-0.7.0-cp39-abi3-musllinux_1_2_aarch64.whl CPython 3.9 abi3 Linux musl 1.2+ ARM64 Details for ptts-0.7.0-cp39-abi3-musllinux_1_2_aarch64.whl
ptts-0.7.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details for ptts-0.7.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
ptts-0.7.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details for ptts-0.7.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
ptts-0.7.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for ptts-0.7.0-cp39-abi3-macosx_11_0_arm64.whl
ptts-0.7.0-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details for ptts-0.7.0-cp39-abi3-macosx_10_12_x86_64.whl

Total release size: 56.6 MB

Release files / ptts-0.7.0.tar.gz

Download URL ptts-0.7.0.tar.gz
Size 325.5 kB
Tags Source
SHA-256 checksum
How to use checksums
fb6c13097666cf447bf4475073c56f9938688848494c668e8227960fa54d0929
BLAKE2b-256 checksum
How to use checksums
667882383f167db6dcb44a816f90faaaf9ac696f49008b057d49a36811c7b39c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / ptts-0.7.0-cp39-abi3-win_arm64.whl

Download URL ptts-0.7.0-cp39-abi3-win_arm64.whl
Size 6.6 MB
Tags CPython 3.9 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
5fff8562639d652a4a90a5f6887095c450a9d4c01a94544254d8d044b2a2fe4c
BLAKE2b-256 checksum
How to use checksums
c33311396feb523c33209f65639e8a8ed71d6d3ef8eb7b1784f890cc5dfcdf3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / ptts-0.7.0-cp39-abi3-win_amd64.whl

Download URL ptts-0.7.0-cp39-abi3-win_amd64.whl
Size 6.9 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
020936f8cef3ec80d736895fb510f1cfbfe8ac5b635c6c6477fc740f07783a6e
BLAKE2b-256 checksum
How to use checksums
e462d33abd76ab80a40f0bea22e692661f0ad27e58a1d3de7526193591000db0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / ptts-0.7.0-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL ptts-0.7.0-cp39-abi3-musllinux_1_2_x86_64.whl
Size 7.5 MB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
4decd6ff1be956b76fa1aeb115fb29569c6fc0b2c7ce7f4762d4c7c503bd24ba
BLAKE2b-256 checksum
How to use checksums
14547b9c7d92e7856c628334a4986291652be90ffc5e1c231d5f634b066f6efa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / ptts-0.7.0-cp39-abi3-musllinux_1_2_aarch64.whl

Download URL ptts-0.7.0-cp39-abi3-musllinux_1_2_aarch64.whl
Size 7.0 MB
Tags CPython 3.9 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
d4042a3f9ac24b2e67c79e213eab389547d9e06b707d745a77373797bb41549e
BLAKE2b-256 checksum
How to use checksums
113717307f2eb8739bd07844ee4fb3a2ff21cf9d60e053048d16dca7c0572d32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / ptts-0.7.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL ptts-0.7.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 7.5 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
15e248596d8c6e17aa2ef6d6867a28a152dfd0d8759a9b63cabc93b58a22d11e
BLAKE2b-256 checksum
How to use checksums
617d9dc240a872d74539ce88bb83f32bd1b82bbfe11778e1927c3cbd7e46a8f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / ptts-0.7.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL ptts-0.7.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 6.9 MB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
63751dbfefb6ed17d8fa345bfe958f518bd6d501e96a03fa9ec5fcbbbc499a8d
BLAKE2b-256 checksum
How to use checksums
2c9db6b3341fda5f76d0e9a024a93ab61f509c17a14f005d44093c56ff0a327a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / ptts-0.7.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL ptts-0.7.0-cp39-abi3-macosx_11_0_arm64.whl
Size 6.9 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
546f3f6d2319a054a3f3bc1838e596a7e41a3ba093e31c8df84bc8d8c4b65c79
BLAKE2b-256 checksum
How to use checksums
4b1dca6bff530716b8ceb0efc4e7e98f1cb03adcc4187a55a559e3cc640b782e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / ptts-0.7.0-cp39-abi3-macosx_10_12_x86_64.whl

Download URL ptts-0.7.0-cp39-abi3-macosx_10_12_x86_64.whl
Size 6.9 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
d7d65cc4cb66ac99d5becf689e6602dd066a2930fd79725d29cfae07cb715bf1
BLAKE2b-256 checksum
How to use checksums
207a7d522f667f2f69f707fa0e2c8ed8e71d56aadb1be88d79d2cba4abee611a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Security for ptts 0.7.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.

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.

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