Skip to main content

tts-rs for Python

Thin PyO3 bindings over the same native Rust engine. Model loading, voice extraction, synthesis, and resampling release the Python interpreter lock. Concurrent operations on one Engine are serialized; create separate engines when independent inference state is needed.

CosyVoice3 is experimental: full-Flow numerical parity remains unresolved, and reported output artifacts include an unrelated leading sound and elongated endings. See the project validation status before using that model. The binding uses the same model implementation as Rust.

python -m pip install candle-tts
import json
from candle_tts import Engine

engine = Engine.load("/models/Qwen3-TTS-12Hz-0.6B-Base", "qwen3", "cpu")
# reference_pcm is mono float32 PCM; pass the actual recording sample rate.
voice = engine.extract_voice(reference_pcm, 24000, "Reference transcript.")
audio = engine.synthesize("Hello.", voice, json.dumps({"seed": 42}))
samples, sample_rate = audio.samples, audio.sample_rate

voice is model-specific conditioning, not a universal biometric identity or a newly trained voice model. Keep its model and schema fields intact when storing it. options_json uses the shared Rust synthesis options and defaults.

Audio(samples, sample_rate) validates finite PCM samples. Accessing .samples copies them to a Python list; no NumPy runtime dependency is required.

The default wheel is CPU-only. Build from source with --features cuda or --features metal for a matching toolchain and target. A feature-enabled binary does not imply a compatible accelerator exists on the current machine.

CosyVoice3's official frontend additionally requires the CPU ONNX Runtime shared library, API 24 or newer. Set ORT_DYLIB_PATH to its absolute path before loading a CosyVoice3 model: libonnxruntime.so on Linux, libonnxruntime.dylib on macOS, or onnxruntime.dll on Windows. Its adjacent runtime dependencies must remain available. Provision the pinned official native runtime from the repository root:

python scripts/install_onnxruntime.py --output .cache/onnxruntime

This repository development tool requires Python 3.12+ for safe archive extraction. This does not change the wheel's CPython 3.10+ requirement.

Then set the environment before constructing a CosyVoice3 engine:

import json
import os
from pathlib import Path

os.environ["ORT_DYLIB_PATH"] = json.loads(
    Path(".cache/onnxruntime/runtime.json").read_text()
)["library"]

An onnxruntime Python wheel may also contain a compatible native library, but its internal layout varies by release and platform; do not assume a fixed path. Inference itself does not call the Python implementation. The import smoke test does not verify this external runtime or execute a model. Candle's CUDA/Metal features accelerate the neural synthesis backend; the ONNX frontend currently stays on CPU.

Prompt JSON is limited to 16 MiB and options JSON to 64 KiB before decoding.

CPython 3.10+ uses the stable abi3 ABI; free-threaded CPython wheels are not included in this distribution. Model support and numerical validation status are documented in the repository root.

Build from source

python -m pip install 'maturin>=1.12,<2'
python -m maturin develop --release --manifest-path bindings/python/Cargo.toml
python bindings/python/tests/smoke.py

Metadata

Release files for candle-tts 0.1.0

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

Built distributions (wheels)

Table of built distributions (wheels) for candle-tts 0.1.0
File Interpreter ABI Platform Actions
candle_tts-0.1.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for candle_tts-0.1.0-cp310-abi3-win_amd64.whl
candle_tts-0.1.0-cp310-abi3-manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.28+ x86-64 Details for candle_tts-0.1.0-cp310-abi3-manylinux_2_28_x86_64.whl
candle_tts-0.1.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for candle_tts-0.1.0-cp310-abi3-macosx_11_0_arm64.whl

Total release size: 12.5 MB

Release files / candle_tts-0.1.0-cp310-abi3-win_amd64.whl

Download URL candle_tts-0.1.0-cp310-abi3-win_amd64.whl
Size 4.2 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
a8d7b92da35ffc5fb81c282033ab381955d2fe14a7bcf266f7f4e7c9fd7bd115
BLAKE2b-256 checksum
How to use checksums
c7d3e498b0b02ec073d9d531dd73b21c18cd3807d0350124c55bf3a2145e6303
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / candle_tts-0.1.0-cp310-abi3-manylinux_2_28_x86_64.whl

Download URL candle_tts-0.1.0-cp310-abi3-manylinux_2_28_x86_64.whl
Size 4.7 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
0b5bca6ee7ac41007dd9360fda1dcf8d18467f8aa2afa288df2703e3591f380a
BLAKE2b-256 checksum
How to use checksums
bed0b83b0ec1d6f76e1c3e1d7ba658238e55a26e16b341fe2f1d28a8c4a1099e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / candle_tts-0.1.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL candle_tts-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
Size 3.6 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f31c44d482fa0bf4ed983d4e494cc5ed6b0ddb8e2b629c55546af79c059ecc1e
BLAKE2b-256 checksum
How to use checksums
6c5cfaf299d22689dd4d846e8f0f6042f7be52e2dde01dcd8fcd408fcf0172b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for candle-tts 0.1.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