Class Definition
Defined in
qwen_tts/inference/qwen3_tts_tokenizer.py:44-61Methods
from_pretrained()
Load a pretrained tokenizer model with HuggingFace-style initialization.Defined in
qwen_tts/inference/qwen3_tts_tokenizer.py:63-99Parameters
HuggingFace model repository ID or local directory path.Examples:
"Qwen/Qwen3-TTS-Tokenizer-25Hz""Qwen/Qwen3-TTS-Tokenizer-12Hz""/path/to/local/model"
Additional keyword arguments forwarded to
AutoModel.from_pretrained().Common options:device_map: Device placement (e.g.,"cuda:0","cpu","auto")torch_dtype: Model precision (e.g.,torch.bfloat16,torch.float16)attn_implementation: Attention implementation (e.g.,"eager","flash_attention_2")
Returns
Initialized tokenizer instance with loaded model, feature extractor, and config.
Example
load_audio()
Load audio from a file path or base64 string and resample to target sample rate.Defined in
qwen_tts/inference/qwen3_tts_tokenizer.py:122-158Parameters
Audio source:
- File path to WAV file
- HTTP/HTTPS URL to audio file
- Base64 encoded audio string (raw or data URL format)
Target sampling rate in Hz for resampling.
Returns
1-D float32 numpy array containing the resampled audio waveform at
target_sr.Example
Utility Methods
get_model_type()
Get the underlying tokenizer model type.Defined in
qwen_tts/inference/qwen3_tts_tokenizer.py:367-375"qwen3_tts_tokenizer_25hz" or "qwen3_tts_tokenizer_12hz"
get_input_sample_rate()
Get the expected input sample rate for encoding.Defined in
qwen_tts/inference/qwen3_tts_tokenizer.py:377-384get_output_sample_rate()
Get the output sample rate for decoded waveforms.Defined in
qwen_tts/inference/qwen3_tts_tokenizer.py:386-393get_encode_downsample_rate()
Get the encoder downsample rate (waveform samples per code step).Defined in
qwen_tts/inference/qwen3_tts_tokenizer.py:395-402get_decode_upsample_rate()
Get the decoder upsample rate (waveform samples per code step).Defined in
qwen_tts/inference/qwen3_tts_tokenizer.py:404-411AudioInput Type
The tokenizer accepts the following input types (defined inqwen_tts/inference/qwen3_tts_tokenizer.py:36-41):