screencastgen

Qwen Backend

Local Qwen3-TTS backend used directly by the CLI or behind the inference server.

Source: screencastgen/providers/tts/qwen_backend.py


Overview

Implements the TTSBackend protocol using Qwen3-TTS for local text-to-speech synthesis. It supports:


Class: QwenTTS

Properties

Property Value Description
max_chunk_bytes 1500 Conservative text limit exposed to chunking and validation
output_format "wav" Output audio format

Constructor

QwenTTS(
    model_name=None,
    ref_audio_path=None,
    ref_text=None,
    language="en-US",
    device="auto",
)
Param Type Default Description
model_name str \| None None Model alias or full Hugging Face model name
ref_audio_path str \| None None Reference audio file for voice cloning
ref_text str \| None None Transcript for the reference audio
language str "en-US" Language code mapped to Qwen language labels
device str "auto" Compute device

Methods

Method Description
synthesize(text, output_path) Generate one audio clip and write it to disk
synthesize_batch(texts, language=None, ref_audio_path=None, ref_text=None) Generate multiple WAV payloads in one model call

Models

Default model:

Built-in aliases:

Supported language map includes:


BackendSpec

Registered in TTS Registry with:

The inference server currently expects this backend to provide synthesize_batch(...).

The model download hook uses huggingface_hub.snapshot_download() to populate the cache without constructing the Qwen model. If the selected model value resolves to a local path, the download step leaves it unchanged.


Dependencies

Qwen Backend
├── qwen-tts            (deferred import)
├── torch               (deferred import)
├── soundfile           (deferred import)
├── TTS Base        (resolve_device, BackendSpec)
└──▶ registered in TTS Registry

See Also