Skip to main content

Class

Qwen3TTSModel is a HuggingFace-style wrapper for Qwen3-TTS models that provides:
  • from_pretrained() initialization via AutoModel/AutoProcessor
  • Generation APIs for CustomVoice, VoiceDesign, and Base models
  • Consistent output format: (wavs: List[np.ndarray], sample_rate: int)
  • Language and speaker validation
Source: qwen_tts/inference/qwen3_tts_model.py:54-878

Constructor

The constructor is typically not called directly. Use from_pretrained() instead.
Qwen3TTSForConditionalGeneration
required
The underlying HuggingFace TTS model instance.
Qwen3TTSProcessor
required
The model’s text processor.
Optional[Dict[str, Any]]
default:"None"
Default generation parameters loaded from generate_config.json.

Class Methods

from_pretrained

Load a Qwen3-TTS model and its processor in HuggingFace from_pretrained style. This method:
  1. Loads the config via AutoConfig (registers qwen3_tts model type)
  2. Loads the model via AutoModel.from_pretrained(...), forwarding kwargs unchanged
  3. Loads the processor via AutoProcessor.from_pretrained(...)
  4. Loads optional generate_config.json from the model directory if present
Source: qwen_tts/inference/qwen3_tts_model.py:82-121

Parameters

str
required
HuggingFace repository ID or local directory path containing the model.Examples:
  • "Qwen3-TTS-CustomVoice-2B"
  • "./local/model/path"
Any
Forwarded as-is into AutoModel.from_pretrained(...).Common examples:
  • device_map="cuda:0" - Load model on specific GPU
  • torch_dtype=torch.bfloat16 - Use bfloat16 precision
  • attn_implementation="flash_attention_2" - Use FlashAttention 2
  • trust_remote_code=True - Trust remote code (if required)

Returns

Qwen3TTSModel
Wrapper instance containing the loaded model, processor, and generation defaults.

Example

Instance Methods

get_supported_languages

List supported language names for the current model. This is a convenience wrapper around model.get_supported_languages(). If the underlying model does not expose language constraints (returns None), this method also returns None. Source: qwen_tts/inference/qwen3_tts_model.py:861-877

Returns

Optional[List[str]]
  • A sorted list of supported language names (lowercased), if available
  • None if the model does not provide supported languages

Example

get_supported_speakers

List supported speaker names for the current model. This is a convenience wrapper around model.get_supported_speakers(). If the underlying model does not expose speaker constraints (returns None), this method also returns None. Note: This is primarily used with CustomVoice models. Source: qwen_tts/inference/qwen3_tts_model.py:842-858

Returns

Optional[List[str]]
  • A sorted list of supported speaker names (lowercased), if available
  • None if the model does not provide supported speakers

Example

Generation Methods

The following generation methods are available on Qwen3TTSModel instances: See Generation Methods and Voice Clone Prompt for complete documentation.

Attributes

Qwen3TTSForConditionalGeneration
The underlying HuggingFace conditional generation model.
Qwen3TTSProcessor
The text processor for tokenization.
Dict[str, Any]
Default generation parameters loaded from generate_config.json.
torch.device
The device where the model is loaded (e.g., cuda:0, cpu).

See Also