Been working on on-device streaming text-to-speech and wanted to share some things I've learned about the architecture trade-offs. Using LinnetTTS as a concrete case study because it's open source and I've got numbers across devices.
Streaming vs batch synthesis
Batch TTS: feed text → wait → get full WAV. Simple, but first-audio latency = full generation time.
Streaming TTS: feed text → get audio chunks as they're generated. First chunk arrives before the rest. Critical when latency matters (voice assistants, interactive UX).
The architecture change isn't trivial. You need:
- A model that can emit partial audio without seeing future context
- A chunked audio pipeline that doesn't underrun the output buffer
- A prime pass that encodes the prompt before first audio
Prime pass vs steady state
When you measure streaming TTS speed you'll see two numbers:
- Prime pass: one-time cost of encoding text + voice prompt (tens of milliseconds)
- Step time: cost per chunk (80 ms of audio in this case)
Reporting "step time" that includes the prime pass makes first-audio look worse than it is. Reporting pure step time hides the actual latency. Both numbers matter and should be reported separately.
Chunk size: why 80 ms
Shorter chunks (e.g. 20 ms) = lower first-audio latency but more overhead per chunk. Longer chunks (e.g. 200 ms) = fewer syscalls but higher first-audio latency.
LinnetTTS uses 80 ms chunks (1920 samples at 24 kHz). That's one sweet spot: close enough to real-time for conversational UX, not so short that per-chunk overhead dominates. Streaming contract: first chunk is slightly shorter (1200 samples), last chunk is 720 zeros, concatenation equals the batch output bit-for-bit.
Voice prompt caching
Voice prompts (the "sound like this" conditioning) can be cached after first use. Second utterance with same voice skips the voice-portion of the prime pass. On an Intel i9 core, that's prime dropping from 67 ms to 14 ms for a 44-character sentence.
CPU benchmarks across devices
Same model, Rust runtime, fp16 weights, measured without real-time pacing:
| device | threads | per 80 ms step | RTF |
|---|
| Apple M5 (macOS) | 1 | 3.3 ms | 4% |
| iPhone 13 Pro Max A15 | 1 | 5.5 ms | 7% |
| iPhone 11 A13 | 1 | 6.7-7.1 ms | 8-9% |
| i9-13900K AVX2 | 1 / 4 | 7.0-7.4 / 2.5 ms | 9 / 3% |
| Pi Zero 2 W (Cortex-A53 1 GHz) | 4 | 59-60 ms | 75% |
RTF = step time / 80 ms. Below 100% = faster than real-time.
Things I learned the hard way
1 thread > 2 threads on A-series. An iPhone A13 step is 6.7 ms and splits into ~80 tiny regions. Waking a worker on another performance core costs about as much as the work it saves. Two threads on A13 = 11.4 ms per step (worse than 1 thread). M-series is different (two threads are about 1.7× faster, roughly 1.9 ms vs 3.3 ms, because M-cores handle wake-up overhead differently).
Playback pacing changes measurement. If you measure synthesis while playback is active with a small queue, the phone's power manager clocks down between steps and you see 3-4× the real cost. Measure unpaced when characterizing throughput.
Chunk boundary gotcha. The first chunk being shorter and the last being zeros feels wrong, but it's necessary so concatenation stays bit-identical to batch synthesis. If you crop them, you lose that guarantee.
Honest trade-offs
- English only at this release
- 83 MB fp16 weights file (runs down to Pi Zero 2 W but Pi 4+ has more headroom)
- Rust runtime under Apache-2.0; weights under a separate free-commercial-use license for the two built-in voices
Links
If you're working on on-device inference and have hit different trade-offs, curious how you handled chunk sizing / prime pass / thread scaling.