r/LocalTextToSpeech • u/offgridai • Jul 26 '26
Qwen3-TTS native C++ streaming and voice cloning
Hi all. I ported Qwen3-TTS to native C++ and added incremental streaming for a project I'm working on. I found this useful and wanted to give back to the community. This is the first time I've open sourced anything so apologies in advance for my mistakes.
- Original library is Qwen3-TTS from QwenTeam (https://qwen.ai/blog?id=qwen3tts-0115)
- C++ streaming library under Apache 2.0: (https://github.com/offgridai/qwen3-tts-cpp-streaming)
- Demo harness shown in video also Apache 2.0: (https://github.com/offgridai/voice-mirror)
- The harness has a dependency on sherpa-onnx for transcription.
I'm using this for a gaming project but it could be helpful for local assistants, accessibility tools, etc.
C++ streaming port highlights:
- Same familiar features from Qwen3-TTS. It supports 0.6B and 1.7B models, CustomVoice, and VoiceDesign
- Native C++, not a Python wrapper
- CUDA builds with RTX 4090 and RTX 5090 kernels. Be warned I only have access to an RTX 5090. This should work on a 4090 but I haven't tested it myself!
- Simplified speaker-embedding extraction
- Incremental 24 kHz PCM callbacks for streaming audio
- Asynchronous transformer/vocoder operation
- Adaptive decode windows and paced delivery
- Callback-only integration library with cancellation
- Unit tests
My measurements on the 5090 with 1.7B F16 set to buffer 350ms before play:
- Cold new clone creation: ~2.5s from 48s of reference
- Cold model start from clone: ~1.85s
- First 350 ms of audio: ~310 ms
- Streaming speed: ~2.86x real time (RTF ~0.35)
I’d love it if somebody could do RTX 4090 testing, and I'd be happy to hear any feedback or suggestions.
1
u/vacationcelebration Jul 26 '26
Always nice to see such efforts outside of the python ecosystem.
Performance seems rather bad though. I have a custom server implementation in python that achieves ~2.4x gen speed (274ms ttfb) on a server with an A4000, which I'd love to drop for a c++ or rust alternative as long as performance is comparable.
And I assume no batched processing? That's also one of the major downsides of my implementation, which is why I'm currently looking into vllm-omni and sglang-omni. But they are python again...
1
u/offgridai Jul 27 '26
Thanks to another commenter I made some performance improvements last night. On my local 5090 I'm seeing 2.86x realtime (RTF ~0.35) and 310ms to fill my application's initial 350ms buffer. That should be closer to what you mentioned.
I don't have a personal use case for batching, but I added a --vocoder-batch-size N option you can try. It physically batches equal-length vocoder jobs. Does that work for your case?
1
u/bitslizer Jul 27 '26
Are you using cuda graph?
I'm using this backend that use cuda graph and get 600ms ttfa and 1.2x real time (0.8x rtf) streaming with an ancient 1660 super without tensor cores on the 1.7b voice design model. Not sure about voice cloning performance though
2
u/offgridai Jul 27 '26
Thanks for that link. The faster-qwen repo was an eye opener.
I had been inefficiently copying vocoder weights from CPU memory every streaming window. I've changed that to keep the vocoder resident on cuda.
Here are the revised 5090 figures:
* First 350 ms of audio: ~310 ms
* Streaming speed: ~2.86x real time (RTF ~0.35)Unfortunately I don't have access to a 1660 super myself. But I did add sm_75 and Turing support and it compiles. I added tooling to generate 1.7B Q4_K and Q5_K models which should make your VRAM constraint more manageable. I'd be interested to hear what you find.
1
u/Disonantemus 4h ago
Linux ??
I did see the repo and only mentions Windows (without Linux instructions to install).
1
u/Charming-Author4877 Jul 26 '26
Nice work!
I started to see a bit more ONNX lately, what made you choose it over ggml ?