Views
No views yet
transformers library with standalone Qwen3TTSTextProcessor implementation that mimics the original.qwen3_tts_inferencer_onnx.py — Core streaming TTS engine that orchestrates six ONNX models (talker LLM, local talker transformer, codec decoder, speaker encoder, talker codec embedding, text embedding projection) using only NumPy and ONNX Runtime.test_qwen3-tts-streaming_onnx.py — End-to-end test script that simulates LLM streaming text and produces a WAV file.Reference Audio ──► Speaker Encoder ──► Speaker Embedding Vector (voice clone context)
│
▼
Text Deltas ──► Talker LLM (Qwen3-0.6B) ──► [Hidden States, VQ Token]
│
▼
Local Transformer ──► 15-codebook RVQ Tokens
│
▼
VQ Token ──► [4 Frames Chunks] ──► Codec Decoder ──► 24 kHz Waveform Chunks (320 ms)| Component | ONNX Model | Description |
|---|---|---|
| Talker LLM | talker_model_*.onnx | Qwen3-based talker LM mapping interleaved text+audio tokens embeddings to hidden states and VQ. Maintains a growing KV-cache across the entire generation. |
| Local Talker | talker_local_model_*.onnx | Depth-wise decoder generating 15 RVQ codebook entries per frame from talker hidden states and VQ. Creates and discards a fresh KV-cache per frame. |
| LM Head of Local Talker | talker_local_lm_head.onnx | Projection head for each of the 15 codebook output of the local talker transformer. |
| Codec Decoder | codec_decoder_model.onnx | Decodes VQ+RVQ audio codes back to 24 kHz waveform. Maintains KV-caches and convolutional caches for streaming decode. |
| Speaker Encoder | speaker_encoder_model.onnx | ECAPA-TDNN-based speaker encoder. Produces a 1024-dim speaker embedding vector for voice identity cloning. |
| Talker Codec Embed | talker_codec_embed_model.onnx | VQ embedding for the talker model. Consists of 2048 token vocabs. |
| Text Embed Projection | text_embed_proj_model.onnx | Text embedding and projection for the talker model. Text embedding consists of 151,936 token vocabs. |
librosa
numpy
onnxruntime-gpu
python-box
soundfile1conda create --name qwen3-tts-streaming-onnx-1 python=3.12
2conda activate qwen3-tts-streaming-onnx-1
3pip install -r requirements.txt.
├── test_qwen3-tts-streaming_onnx.py # End-to-end test script
├── README.md
├── requirements.txt
├── qwen3-tts_onnx/ # FP32
│ ├── talker_model_prefill.onnx
│ ├── talker_model_step.onnx
│ ├── talker_local_model_prefill.onnx
│ ├── talker_local_model_step.onnx
│ ├── talker_local_lm_head.onnx
│ ├── codec_decoder_model.onnx
│ ├── speaker_encoder_model.onnx
│ ├── talker_codec_embed_model.onnx
│ └── text_embed_proj_model.onnx
├── configs/
│ ├── config.json # Talker, Local Talker, Speaker Encoder config
│ ├── speech_tokenizer_config.json # Codec config
│ ├── preprocessor_config.json # Text Processor configs
│ ├── tokenizer_config.json
│ ├── vocab.json
│ └── merges.txt
├── src/
│ ├── inference/
│ │ └── qwen3_tts_inferencer_onnx.py # Core ONNX inference engine
│ └── utils/
│ └── audio_utils.py
├── logs/
│ └── <log_synth>.txt
├── audio_ref/
│ └── <reference_speaker>.[wav|mp3|flac]
└── audio_synth/
└── <synthesized_example>.wav1python -u test_qwen3-tts-streaming_onnx.py >& logs/log_test-streaming-onnx-1.txt
2# audio automatically saved in audio_synth/ with default parameters, text, language.python test_qwen3-tts-streaming_onnx.py \
--onnx_dir qwen3-tts_onnx/ \
--model_config_path configs/config.json \
--codec_config_path configs/tokenizer_config.json \
--preprocessor_config_dir configs/ \
--temperature 0.75 \
--top_p 0.85 \
--top_k 50 \
--repetition_penalty 9.5 \
--repetition_window 75 \
--num_threads 4 \
--audio_ref_path audio_ref/speaker.[wav|flac|mp3] \
--out_wav output.wav \
--text "Text to be synthesized" "Yet another text here" "And another" \
--language "english""chinese", "zh", "english", "en", "german", "de", "italian", "it", "portuguese", "pt",
"spanish", "es", "japanese", "ja", "korean", "ko", "french", "fr", "russian", "ru"1from src.inference import Qwen3TTSInferencerONNX
2
3# Create inferencer
4inferencer = Qwen3TTSInferencerONNX(
5 talker_prefill, talker_step, talker_local_prefill, talker_local_step,
6 talker_local_lm_head, codec_decoder, codec_decoder_dynamic,
7 speaker_encoder, talker_codec_embed, text_embed_proj,
8 preprocessor_config_dir, model_config, codec_config,
9 audio_ref_path, language,
10)
11inferencer.reset_turn(reset_cache=True, force_reset_codec_cache=True)
12
13# Stream text and collect audio
14for delta in your_llm_stream():
15 audio_frames = inferencer.push_text(delta)
16 ...
17 for audio_tokens in audio_frames:
18 ...
19 inferencer.push_tokens(audio_tokens)
20 for wav in inferencer.audio_chunks():
21 ...
22 yield wav
23# End of text and collect audio
24audio_frames = inferencer.end_text()
25for audio_tokens in audio_frames:
26 ...
27 inferencer.push_tokens(audio_tokens)
28 for wav in inferencer.audio_chunks():
29 ...
30 yield wav
31# Drain remaining audio (text will be with pad token)
32audio_frames = inferencer.drain()
33for audio_tokens in audio_frames:
34 ...
35 inferencer.push_tokens(audio_tokens)
36 for wav in inferencer.audio_chunks():
37 ...
38 yield wav
39# Flush any remaining audio tokens
40for wav in inferencer.flush():
41 ...
42 yield wav| Argument | Type | Default | Description |
|---|---|---|---|
--onnx_dir | str | "qwen3-tts_onnx/" | Directory path to all onnx models |
--preprocessor_config_dir | str | "configs/" | Directory path to configuration files for the Qwen3 text tokenizer |
--model_config_path | str | "configs/config.json" | Path to original model configuration file for the Qwen3-TTS-12Hz-0.6B-Base |
--codec_config_path | str | "configs/speech_tokenizer_config.json" | Path to original model configuration file for the codec of Qwen3-TTS-12Hz-0.6B-Base |
--temperature | float | 0.75 | Sampling temperature |
--top_p | float | 0.85 | Nucleus sampling threshold |
--top_k | int | 50 | Top-k sampling cutoff |
--repetition_penalty | float | 9.5 | Repetition penalty coefficient |
--repetition_window | int | 75 | Window for repetition penalty |
--delta_chunk_chars | int | 1 | Characters per simulated LLM delta |
--delta_delay_s | float | 0.0 | Delay between simulated deltas (seconds) |
--num_threads | int | 4 | Number of threads used in sess.intra_op_num_threads of the onnxruntime session options |
--prompt_wav | str | audio_ref/male_stewie.mp3 | Reference speaker audio for voice cloning |
--out_wav | str | out_streaming.wav | Output WAV file path |
--text | str | (Russian text) | Text to synthesize |
--language | str | "russian" | Language of the text to synthesize |
1@misc{vertoxai2026qwen3ttsstreamingonnxcudagraph,
2 title={Qwen3-TTS-Streaming-ONNX — VertoX-AI},
3 author={Tobing, P. L., VertoX-AI},
4 year={2026},
5 publisher={HuggingFace},
6}Created by: Patrick Lumbantobing, Vertox-AI
Copyright (c) 2026 Vertox-AI. All rights reserved.
This work is licensed under the Apache License, Version 2.0.
To view a copy of this license, visit [LICENSE](https://huggingface.co/datasets/choosealicense/licenses/blob/main/markdown/apache-2.0.md).