Skip to main content

Python ctypes bindings and wheel packaging for qwentts.cpp

Project description

qwentts-cpp-python

Python bindings and wheel packaging for Pascal's qwentts.cpp C ABI.

This package is intentionally small:

  • it loads libqwen with ctypes
  • it exposes buffered and streaming synthesis
  • it can bundle prebuilt libqwen/libggml binaries in platform wheels
  • it does not bundle GGUF model weights

CUDA development build with an existing qwentts.cpp checkout:

python scripts/build_native.py \
  --source /path/to/qwentts.cpp \
  --backend cuda \
  --clean
QWENTTS_CPP_WHEEL_BUILD_TAG=1cu128 python -m build --wheel

CPU development build:

python scripts/build_native.py \
  --source /path/to/qwentts.cpp \
  --backend cpu \
  --clean
QWENTTS_CPP_WHEEL_BUILD_TAG=1cpu python -m build --wheel

--backend cuda is the default because faster-qwen3-tts is a CUDA-first package. CPU builds are still useful for development and smoke tests, but they are not the primary release target.

Installation

The default PyPI package is built for CUDA 12.8:

pip install qwentts-cpp-python

Additional backend-specific wheels are published to Hugging Face Hub as local-version variants. Use them when the PyPI CUDA 12.8 wheel does not match the runtime or GPU target, for example DGX Spark / GB10 with CUDA 13:

pip install "qwentts-cpp-python==0.3.0+cpu" \
  -f https://huggingface.co/datasets/andito/qwentts-cpp-python-wheels/resolve/main/whl/cpu.html

pip install "qwentts-cpp-python==0.3.0+cu124" \
  -f https://huggingface.co/datasets/andito/qwentts-cpp-python-wheels/resolve/main/whl/cu124.html

pip install "qwentts-cpp-python==0.3.0+cu128" \
  -f https://huggingface.co/datasets/andito/qwentts-cpp-python-wheels/resolve/main/whl/cu128.html

pip install "qwentts-cpp-python==0.3.0+cu130" \
  -f https://huggingface.co/datasets/andito/qwentts-cpp-python-wheels/resolve/main/whl/cu130.html

Hugging Face raw file hosting does not expose a PyTorch-style package directory index, so these commands use pip's --find-links mode. Dependencies still resolve from PyPI normally. The wheels do not bundle CUDA runtime or cuBLAS libraries; use a base image or system installation that provides the matching CUDA runtime.

The CI wheel build defaults to qwentts.cpp 9dbe7ea26a01b30fccb117ae5e86807c1dc23d42, which includes the scheduler resets and ABI v2 cached voice-reference fields. CPU and CUDA both stay on the backend prompt-projection path.

QWENTTS_CPP_WHEEL_BUILD_TAG is useful for local wheelhouses. For public indexes, publish one backend flavor per package/version/platform compatibility tag; otherwise pip has no way to choose between CPU and CUDA binaries.

Local smoke test with a built library:

QWENTTS_CPP_LIBRARY=/path/to/libqwen.so python - <<'PY'
from qwentts_cpp import QwenLibrary
lib = QwenLibrary()
print(lib.version())
PY

Model files are resolved with huggingface-hub by QwenTTS.from_pretrained(...) or passed directly to QwenTTS(...) as GGUF paths.

Cached voice references

qwentts.cpp ABI v2 can skip reference WAV encoding for Base voice cloning by passing precomputed latents:

  • .spk: raw float32 speaker embedding from qwen-codec --talker
  • .rvq: packed 11-bit reference codec stream from qwen-codec

The wrapper can create those files in-process from decoded mono float32 audio at 24 kHz:

from qwentts_cpp import QwenTTS

tts = QwenTTS.from_pretrained("Qwen/Qwen3-TTS-12Hz-1.7B-Base", quant="Q4_K_M")

# ref_audio_24k is a 1-D numpy float32 array, already resampled to 24 kHz.
voice_ref = tts.extract_voice_ref(ref_audio_24k)
voice_ref.save("reference.spk", "reference.rvq")
from qwentts_cpp import QwenTTS, load_speaker_embedding

tts = QwenTTS.from_pretrained("Qwen/Qwen3-TTS-12Hz-1.7B-Base", quant="Q4_K_M")

spk = load_speaker_embedding("reference.spk")
audio, sr = tts.synthesize(
    text="The sky is blue today.",
    lang="english",
    ref_spk_emb=spk,
    max_new_tokens=128,
)

For ICL clone mode, load the RVQ matrix with the model's codebook count and also pass the reference transcript:

from qwentts_cpp import load_rvq_codes

rvq = load_rvq_codes("reference.rvq", tts.num_codebooks())
audio, sr = tts.synthesize(
    text="The sky is blue today.",
    lang="english",
    ref_spk_emb=spk,
    ref_codes=rvq,
    ref_text="Transcript of the reference audio.",
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

qwentts_cpp_python-0.3.0-1cu128-py3-none-manylinux_2_39_x86_64.whl (104.2 MB view details)

Uploaded Python 3manylinux: glibc 2.39+ x86-64

qwentts_cpp_python-0.3.0-1cu128-py3-none-manylinux_2_39_aarch64.whl (104.0 MB view details)

Uploaded Python 3manylinux: glibc 2.39+ ARM64

File details

Details for the file qwentts_cpp_python-0.3.0-1cu128-py3-none-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for qwentts_cpp_python-0.3.0-1cu128-py3-none-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 dc92170416b556f876da405ac329a82bbb6ffb8f73e6b586cf7131bd4767ccdd
MD5 b00ccf32115cce00b81e8cc8c0cc5504
BLAKE2b-256 d384625bb9c3dc55be92b07b9b4e103691ee9ec9f653b2622fa3a92c6f4fe95c

See more details on using hashes here.

Provenance

The following attestation bundles were made for qwentts_cpp_python-0.3.0-1cu128-py3-none-manylinux_2_39_x86_64.whl:

Publisher: publish.yml on andimarafioti/qwentts-cpp-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qwentts_cpp_python-0.3.0-1cu128-py3-none-manylinux_2_39_aarch64.whl.

File metadata

File hashes

Hashes for qwentts_cpp_python-0.3.0-1cu128-py3-none-manylinux_2_39_aarch64.whl
Algorithm Hash digest
SHA256 1e7da4102b27f3051859ba30df5d61708cf624b96279e2f056755a7e9b18e199
MD5 4329cddc349216d0b60962beb397a7fe
BLAKE2b-256 4334848d2d4f51ce8e63479564db2baefd33020f0644be1b667f92eef78acec0

See more details on using hashes here.

Provenance

The following attestation bundles were made for qwentts_cpp_python-0.3.0-1cu128-py3-none-manylinux_2_39_aarch64.whl:

Publisher: publish.yml on andimarafioti/qwentts-cpp-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page