Text-to-Speech
ONNX
GGUF
Chinese
English
onnxruntime
tts
on-device
jetson
telephony
vits
mb-istft-vits
multi-speaker
mandarin
taiwanese-mandarin
imatrix
conversational
Instructions to use quacklater/PrimeTTS with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use quacklater/PrimeTTS with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf quacklater/PrimeTTS:F32 # Run inference directly in the terminal: llama cli -hf quacklater/PrimeTTS:F32
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf quacklater/PrimeTTS:F32 # Run inference directly in the terminal: llama cli -hf quacklater/PrimeTTS:F32
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf quacklater/PrimeTTS:F32 # Run inference directly in the terminal: ./build/bin/llama cli -hf quacklater/PrimeTTS:F32
Use Docker
docker model run hf.co/quacklater/PrimeTTS:F32
- Llama new
- LM Studio
- Jan
- Ollama
How to use quacklater/PrimeTTS with Ollama:
ollama run hf.co/quacklater/PrimeTTS:F32
- Unsloth Desktop
- Docker Model Runner
How to use quacklater/PrimeTTS with Docker Model Runner:
docker model run hf.co/quacklater/PrimeTTS:F32
- Lemonade
How to use quacklater/PrimeTTS with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull quacklater/PrimeTTS:F32
Run and chat with the model
lemonade run user.PrimeTTS-F32
List all available models
lemonade list
- Atomic Chat
File size: 14,466 Bytes
688d476 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | ---
license: apache-2.0
language:
- zh
- en
tags:
- text-to-speech
- tts
- onnx
- gguf
- on-device
- jetson
- telephony
- vits
- mb-istft-vits
- multi-speaker
- mandarin
- taiwanese-mandarin
base_model: owensong/Inflect-Nano-v1
base_model_relation: finetune
library_name: onnxruntime
pipeline_tag: text-to-speech
---
> **Mirror.** A copy of [Luigi/PrimeTTS](https://huggingface.co/Luigi/PrimeTTS) at commit `7c47a46121d7006b2fc3cf7c49349fe5a86a9c5d` (model files unchanged; only this notice added), hosted for the Quack Later app's on-device voices. All credit belongs to the original authors. Licensed under Apache-2.0, as the original. The original model card follows.
# PrimeTTS — on-device zh-TW + English TTS
Taiwan-Mandarin + English text-to-speech built for on-device use (contact-centre, GPS, transit): one
frontend handles Chinese, English, and **code-mix** with no language routing, and reads **entities**
correctly — phone numbers, emails, addresses, prices, dates, temperatures, %, serials.
**Two models to know:**
| | **PrimeTTS v2.1** — flagship | **PrimeTTS v1** — leanest CPU |
|---|---|---|
| Folder | [`v21_mbistft_16k/`](./v21_mbistft_16k) | [`v1b_16k/`](./v1b_16k) · [`v1b_8k/`](./v1b_8k) |
| Architecture | MB-iSTFT-VITS (end-to-end, multi-speaker) | FastSpeech + Snake-HiFiGAN (+ pitch refiner) |
| Params | 37.9M | ~5.0M (16 kHz) / 4.09M (8 kHz) |
| Voices | **3 selectable** — Xinran ♀, Anchen ♂, Bowen ♂ | 1 — young ♀ zh-TW |
| Sample rate | 16 kHz | 16 kHz / 8 kHz |
| Held-out CER | **0.059** (zh/mix/en, 3-voice avg) | 0.11–0.15 (zh) |
| Best on | Jetson Nano **GPU** (also any CPU) | pure **CPU** — Nano **RTF 0.35** (8 kHz, 1 thread) |
Pick **v2.1** for multiple voices; pick **v1** when the budget is CPU-only and tight.
**The full family** (all MB-iSTFT-VITS except v1; all 16 kHz; single Xinran voice unless noted):
| model | folder | params (deploy) | CER | use when |
|---|---|---|---|---|
| **v2** | `v2_mbistft_16k/` | 34.7M (17.5M) | **0.027** | you want the cleanest single Xinran voice |
| **v2.1** | `v21_mbistft_16k/` | 37.9M (~18M) | 0.059 | you want a choice of 3 voices |
| **V2 Lite** | `v2lite_mbistft_16k/` | 24.8M (17.5M) | 0.041 | a lighter, still-good single voice for tighter GPU budgets |
| **v1** | `v1b_16k/`,`v1b_8k/` | ~5M | 0.11–0.15 | pure-CPU, real-time on a Jetson Nano |
(`v3_4.6M/` and the top-level `*.onnx` are legacy 24 kHz variants, kept for provenance.) V2 Lite uses the exact
same ONNX I/O + frontend as v2 — it's a drop-in, smaller replacement.
> 🔊 **Live demo:** https://huggingface.co/spaces/Luigi/PrimeTTS-vs-Inflect-Nano-v1 — pick a model, pick a voice, type text.
---
## PrimeTTS v2.1 (`v21_mbistft_16k/`)
End-to-end **MB-iSTFT-VITS** (VAE + normalizing flow + adversarial multi-band iSTFT head; conv-only, no LSTM)
with **3 selectable Taiwan-Mandarin voices**, chosen by an integer `sid` input (0 = Xinran ♀, 1 = Anchen ♂,
2 = Bowen ♂). 37.9M generator params, 16 kHz, `gin_channels=256` speaker conditioning.
**Quality** (36 held-out zh / code-mix / en sentences, X-ASR normalized CER):
| voice (`sid`) | CER | note |
|---|---|---|
| Xinran ♀ (0) | **0.059** | flagship voice, cleanest teacher |
| Anchen ♂ (1) | 0.069 | slight accent |
| Bowen ♂ (2) | 0.066 | slight accent |
### On-device deployment (measured, Jetson Nano gen-1 / Tegra X1)
Same runtime profile as the single-voice v2 (identical architecture). RTF = compute-time ÷ audio-time
(lower is faster; < 1.0 = real-time).
| Tier | Runtime | Precision | RTF | Notes |
|---|---|---|---|---|
| **GPU** | RapidSpeech.cpp ggml-CUDA, 1 CPU thread | fp32 | **0.42** (2.4× RT) | launch-bound floor on Maxwell (sm_53, no CUDA-graph replay) |
| **CPU** *(default)* | onnxruntime, 4 threads | fp32 | **0.52** (1.9× RT) | full quality, 117 MB |
| **CPU** | onnxruntime, 2 threads | fp32 | **0.77** (1.3× RT) | fewer cores, leaves headroom |
Both tiers are full-fidelity and need no GPU. On this ARMv8.0 Cortex-A57, **fp32 is the fast format**:
**int8 is not a speed lever** (static-int8 shifts the voice; dynamic-int8 preserves it but runs *slower* than
fp32 — no dot-product / no FP16 arithmetic on this core), fp16 casts to fp32 (no speedup), and XNNPACK ≈ MLAS.
The only on-device speed lever is a smaller/faster **architecture**, not quantization.
### Files
```
v21_mbistft_16k/primetts_v21_3voice.onnx 3-voice fp32 (117 MB) — full quality, all runtimes
```
### Quickstart
```bash
pip install onnxruntime numpy soundfile g2pw g2p_en cn2an
huggingface-cli download Luigi/PrimeTTS --local-dir PrimeTTS
```
```python
import sys; sys.path.insert(0, "PrimeTTS/scripts")
import numpy as np, onnxruntime as ort, soundfile as sf
import frontend_bopomofo as F # g2pw bopomofo + g2p_en, one pass
sess = ort.InferenceSession("PrimeTTS/v21_mbistft_16k/primetts_v21_3voice.onnx",
providers=["CPUExecutionProvider"])
o = F.text_to_ids("您好,歡迎使用 PrimeTTS。Thank you for calling.")
blank = lambda s: np.array([[0] + [v for x in s for v in (x, 0)]], np.int64) # add_blank=true
sid = 0 # 0 Xinran ♀ · 1 Anchen ♂ · 2 Bowen ♂
wav = sess.run(None, {
"x": blank(o["phone_ids"]), "tone": blank(o["tone_ids"]), "lang": blank(o["lang_ids"]),
"x_lengths": np.array([2*len(o["phone_ids"])+1], np.int64),
"sid": np.array([sid], np.int64),
"noise_scale": np.array([0.667], np.float32),
"length_scale": np.array([1.0], np.float32)})[0].reshape(-1)
sf.write("out.wav", wav, 16000)
```
---
## PrimeTTS v1 (`v1b_16k/`, `v1b_8k/`) — tiny, CPU-only
FastSpeech-style acoustic (**no attention**: depthwise gated Conv-FFN + external durations + length regulator
+ BiGRU + postnet) with a **97K-param frame-pitch refiner** that turns per-phoneme pitch into the per-frame F0
contour = Mandarin tones (ablating it costs +18% relative zh-CER), and a **Snake-HiFiGAN** vocoder. Torch-free
ONNX; runs real-time on a Jetson Nano CPU. One young-female zh-TW voice across zh / en / code-mix.
| | flagship `v1b_16k/` | leanest `v1b_8k/` |
|---|---|---|
| Params | **~5.0M** (3.56M acoustic + 1.43M vocoder) | **4.09M** (+ 0.53M vocoder) |
| Sample rate | 16 kHz (0–8 kHz band) | 8 kHz (telephone band) |
| Jetson Nano RTF | (heavier) | **0.35** (1 thread) |
| `.gguf` (ggml) | — | `inflect_combined_v1b.gguf` |
Pipeline is `encoder → numpy length-regulator → decoder → vocoder`:
```python
import sys; sys.path.insert(0, "PrimeTTS/scripts")
import json, numpy as np, onnxruntime as ort, soundfile as sf
import frontend_bopomofo as F
from synth_from_text import host_regulate
D = "PrimeTTS/v1b_16k" # or v1b_8k for the leanest Nano RTF
meta = json.load(open(f"{D}/meta.json"))
enc = ort.InferenceSession(f"{D}/acoustic_encoder.onnx", providers=["CPUExecutionProvider"])
dec = ort.InferenceSession(f"{D}/acoustic_decoder.onnx", providers=["CPUExecutionProvider"])
voc = ort.InferenceSession(f"{D}/vocoder.onnx", providers=["CPUExecutionProvider"])
o = F.text_to_ids("您好,歡迎使用 PrimeTTS。Thank you for calling.")
ph, tn, lg = (np.array([o[k]], np.int64) for k in ("phone_ids", "tone_ids", "lang_ids"))
cond, dur, pitch = enc.run(None, {"phone": ph, "tone": tn, "lang": lg, "speaker": np.zeros(1, np.int64)})
reg = host_regulate(cond, dur, pitch, meta["abs_frame_bins"], meta["max_frames"])
mel = dec.run(None, {k: reg[k] for k in ["frames","frame_meta","local_ctx_raw","abs_pos","pitch_frame","frame_mask"]})[0]
wav = voc.run(None, {"mel": mel.astype(np.float32)})[0].reshape(-1)
sf.write("out.wav", wav, meta["sample_rate"])
```
`scripts/synth_long.py` adds punctuation auto-chunking for long text.
---
## Shared frontend
`g2pw` (Taiwan bopomofo + polyphone disambiguation) + `g2p_en` (arpabet) merge into one phone sequence with
per-phone **language ids** — zh / en / code-mix in a single pass, **88-symbol table**. Entity normalization
(`scripts/text_norm.py`) reads numbers / dates / prices / emails / addresses / serials and spells acronyms
(VIP → V-I-P), applied identically in training and inference. Both model families consume the *same*
`frontend_bopomofo.text_to_ids()` output (phone / tone / lang ids).
---
## Reproduce from this repo
Everything needed to rebuild both models is here: the frontend, entity normalizer, aligner, corpus-gen and
text-selection scripts, the eval sets + scorer, the export scripts, and the v1 trainer.
```
scripts/ frontend_bopomofo.py · text_norm.py · align_durations_v4.py · build_corpus_v3.py
gen_codemix*.py · gen_entity_texts.py · select_diverse_text.py · asr_filter.py
synth_from_text.py · synth_long.py · export_8k.py · export_onnx_primetts_v21.py
xasr_offline.py · assess_big.py · rebuild_voice.sh · symbol_table.json
data/ codemix_v2.txt · entity_texts.jsonl · voxcpm_texts.jsonl (corpus text sources)
eval_big.jsonl · eval_entity.jsonl (held-out eval sets)
inflect_nano/ the v1 trainer (acoustic.py + vocoder.py), forked from Inflect-Nano-v1
configs/ zhtw_mb_istft_16k_v21b.json (v2.1 3-voice training config)
```
**Common recipe (both models):** `teacher corpus → ASR/CER gate → phone-level align → train → export`.
The three levers that matter for a tiny model: **phone-level alignment** (espeak phoneme-CTC +
`torchaudio.forced_align` — sub-syllable boundaries separate speech from fluent babble), **broad coverage +
diverse code-mix**, and **the teacher** (a student's language is only as good as its teacher's).
**v1** (`inflect_nano/` trainer, all in-repo):
1. Generate corpus text — `scripts/gen_codemix_v2.py`, `gen_entity_texts.py`, `select_diverse_text.py`.
2. Synthesize with the teacher (VoxCPM2 cloning a CC0 zh-TW reference), gate with `asr_filter.py`.
3. Align — `scripts/align_durations_v4.py`. Train acoustic + vocoder (`inflect_nano/`). Export — `scripts/export_8k.py`.
4. One-shot: **`scripts/rebuild_voice.sh`** (swap in your own ~10 s reference clip).
**v2.1** (MB-iSTFT-VITS; trainer is the upstream repo — see credits):
1. Synthesize the corpus with a **VibeVoice-Large** teacher across the 3 zh-capable voices.
2. **CER-gate the teacher audio** (X-ASR normalized CER < 0.05) — *not* voice-similarity — so only intelligible
clips train the model. (This is the single most important QC step; ungated multi-voice teacher audio is the
main failure mode.)
3. Train the 3-speaker MB-iSTFT-VITS (`configs/zhtw_mb_istft_16k_v21b.json`, `n_speakers=3`, `gin_channels=256`),
warm-started from the single-voice v2 with **fresh** speaker-conditioning layers.
4. Export to ONNX — **`scripts/export_onnx_primetts_v21.py`** (opset 17, `dynamo=False`; the tiny gen-head
iSTFT `n_fft=16, hop=4` is replaced by an exact irFFT + overlap-add matrix, verified vs `torch.istft`).
5. Score — `scripts/xasr_offline.py` + `assess_big.py` on `eval_big.jsonl`.
---
## Findings & lessons (what building tiny on-device zh/en TTS actually taught us)
Transferable lessons from taking this from a babbling 5M model to a shippable family. Full analysis in
[`docs/zh-en-tts-arch-survey-2026.md`](./docs) and [`docs/streaming-arch-design.md`](./docs).
- **A tiny model's quality is bounded by its *inputs*, not its parameter count.** Held-out Mandarin CER fell
**0.88 → 0.06 at a fixed ~5M** purely from **phone-level forced alignment** + broad character coverage —
no architecture change. Sub-syllable (not character) boundaries are the difference between intelligible
speech and fluent babble. **Gate on resynth CER, not on how balanced the duration histogram looks.**
- **CER-gate the *teacher* audio, never voice-similarity alone.** Our first multi-speaker attempt trained on
teacher clips filtered only for the right *voice*; four of the "voices" were speakers that can't actually
pronounce Mandarin (teacher CER 0.45–0.79), and the student faithfully learned garbled speech. Filtering on
intelligibility (teacher X-ASR CER < 0.05) fixed it.
- **Deterministic (FastSpeech-class) models mean-regress prosody; distributional (VITS/flow) models don't.**
This is the wall that caps a tiny deterministic model at "intelligible but flat" — and why the flagship is
a VITS, not a bigger FastSpeech.
- **On a launch-bound GPU (Maxwell sm_53, no CUDA-graph replay), RTF is set by kernel *count*, not FLOPs.** A
smaller VITS is a smaller download but **not faster** (~0.42 RTF floor regardless of params). The lever for
*speed* is an architecture with fewer, larger kernels (flow-matching + Vocos measured ~0.18) — a different
axis from *size*.
- **On an ARMv8.0 CPU (Cortex-A57): fp32 is the fast format.** No int8 dot-product and no fp16 arithmetic, so
int8 either breaks the voice (static) or runs *slower* than fp32 (dynamic), fp16 casts to fp32, and XNNPACK
≈ MLAS. The only CPU speed lever is a smaller/faster architecture — quantization is a *download-size* option.
- **"Lighter" and "faster" are different goals.** VITS deploy size is dominated by flow + decoder + encoder,
which don't shrink with `hidden_channels`; below ~17M deploy, quality craters. **V2 Lite (17.5M) is the
practical quality floor** for this arch — there is no free "smaller *and* still good."
## Credits & licenses
- **v2.1 architecture:** [MB-iSTFT-VITS](https://github.com/MasayaKawamura/MB-iSTFT-VITS) (Kawamura et al., Apache-2.0) ·
Jetson-Nano ggml-CUDA runtime: [RapidSpeech.cpp](https://github.com/vieenrose/RapidSpeech.cpp) (`mbistft-vits` arch)
- **v2.1 teacher:** VibeVoice-Large (Microsoft, **MIT**), 3 zh-capable presets (via the MIT
[community repo](https://github.com/vibevoice-community/VibeVoice)) — synthesized / AI-generated voices; mark as such in products
- **v1 base / trainer:** [`owensong/Inflect-Nano-v1`](https://huggingface.co/owensong/Inflect-Nano-v1) (Apache-2.0) ·
**v1 teacher:** [`openbmb/VoxCPM2`](https://huggingface.co/openbmb/VoxCPM2) ·
**v1 reference voice:** [Mozilla Common Voice zh-TW](https://commonvoice.mozilla.org/datasets) (**CC0 / public domain**)
- **Gate ASR:** Breeze-ASR-25 (MediaTek Research) · Whisper · **Aligner:**
`facebook/wav2vec2-lv-60-espeak-cv-ft` + `torchaudio.forced_align` · **Eval:** sherpa-onnx X-ASR
This repository: **Apache-2.0**.
|