File size: 9,449 Bytes
cbf0160
 
 
 
 
 
 
 
 
 
 
 
04c6033
 
cbf0160
 
 
74caa62
cbf0160
62a37ac
cbf0160
6309a0a
 
 
04c6033
62a37ac
 
 
74caa62
 
 
 
 
 
 
 
62a37ac
 
 
 
 
 
 
 
cbf0160
04c6033
 
 
 
 
 
cbf0160
 
04c6033
 
74caa62
 
 
62a37ac
04c6033
 
 
 
 
cbf0160
04c6033
cbf0160
04c6033
cbf0160
04c6033
 
 
 
 
 
 
 
cbf0160
74caa62
cbf0160
 
0f2eea6
 
 
04c6033
0f2eea6
 
74caa62
 
cbf0160
 
0f2eea6
 
cbf0160
 
 
74caa62
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
---
license: apache-2.0
language:
- vi
pipeline_tag: text-to-speech
tags:
- tts
- vietnamese
- onnx
- wasm
- browser
- vocos
- hn-vocos
- multi-speaker
- tiny-voca
---

# TinyVoca-Vi (v0.2.2)

Ultra-lightweight (**4.77M parameters**, **12.39 MB Brotli**, **3 Northern Vietnamese female voices in ONE ONNX file**, **24 kHz mono**) Text-to-Speech model designed to run **100% client-side in the browser** via single-thread ONNX Runtime Web (WASM SIMD)—no backend, no Python at runtime, works offline after first load.

- **Try Live in Browser (HF Space, 100% Client-Side WASM):** [huggingface.co/spaces/datmt24/tiny-voca-vi](https://huggingface.co/spaces/datmt24/tiny-voca-vi)
- **Try Live in Browser (GitHub Pages):** [datmt.github.io/tiny-voca-vi](https://datmt.github.io/tiny-voca-vi/)
- **Code, G2P & training scripts:** [github.com/datmt/tiny-voca-vi](https://github.com/datmt/tiny-voca-vi)
- **Voices (3 Northern *miền Bắc* female voices in v0.2):**
  - `voice_id = 1` — **Quỳnh Anh** *(recommended default)*: Storytelling timbre, clearest tones (**`0.09%` CER**)
  - `voice_id = 2` — **Trúc Ly**: Youngest, brisk & expressive timbre
  - `voice_id = 0` — **Mai Anh**: Crisp news-anchor timbre
- **Front-end:** `~15 KB` gzipped deterministic rule-based Northern Vietnamese G2P (`web/g2p.js` / `src/tiny_voca_vi/g2p.py`) plus an English word list (`web/en_lexicon.js`, ~250 KB gzipped, derived from CMUdict).

## What's New in v0.2.2

- **Foreign words are read as English, with stress and rhythm:** about 39,000 English words and names are respelled from CMUdict (*lake* → "lếch", *update* → "ấp đết"). Other words keep the letter rules; main stress is guessed with the Latin rule (*Palsada* → **pan**-sa-đa).
- **New `stress` input in the ONNX graph:** per-token duration, pitch and energy offsets. No retraining: the weights are those of v0.2.1 and Vietnamese text without foreign words gives identical audio (max difference 0 on 60 sentences, 3 voices). **Breaking for direct ONNX users:** `stress` is required; pass `(1, 0, 0)` for every token to get the v0.2.1 behaviour.
- **Uneven rhythm:** middle syllables of a foreign word are compressed, so syllables no longer arrive on an even beat. On 400 held-out words in a Vietnamese carrier sentence, `whisper-large-v3-turbo` writes the English word for 145–148 with stress against 113–131 without (per voice). On a separate set of 300 words, *Quỳnh Anh*, the new readings alone went from 49 to 82.
- **Known limits:** consonant clusters (*cl-*, *st-*) are still rarely recognised, because the model was trained on Vietnamese only; names outside the dictionary are read by letter rules.

## What's New in v0.2.1

- **Pauses in the right places:** punctuation inside a sentence now gets a minimum pause in the ONNX graph (comma 160 ms, inner full stop 300 ms, scaled by `pause` and `speed`). In v0.2 *Quỳnh Anh* skipped about half of all commas. Brackets, spaced dashes, line breaks, `...`, `v.v.`, initials and number ranges are handled in the text front-end, and the demo adds a gap between sentences.
- **Clear *p* sounds (*Sa Pa*, *Paris*, *pound*):** fine-tuned on 0.8 h of p-rich speech (v0.2's *Quỳnh Anh* data had 6 *p* onsets). A phoneme recognizer hears *p* as *p* on held-out sentences: *Quỳnh Anh* 28% → 85%, *Mai Anh* 41% → 81%, *Trúc Ly* 61% → 87%.
- **Reads abbreviations, currencies, units, English and foreign words:** `4.000 USD/ounce`, `UBND TP.HCM`, `10h30`, *Opasada*, and the look-alike `Ð`.
- **Tones, stated plainly:** on the 48-word test *Quỳnh Anh* scores 79.2% (v0.2: 87.5%), *Trúc Ly* 91.7% (85.4%), *Mai Anh* 75.0% (77.1%). On a wider test (same 48 words, 3 carrier sentences, 2 recognizers) they score 86.6% / 84.0% / 79.5% against 84.2% / 83.0% / 81.9%, so we see no clear change overall.
- **Known limits:** long sentences without punctuation get no breath; *Trúc Ly* has a 7–8% word error rate on the general sentences in both versions.

## What's New in v0.2

- **Voicing-Gated Pitch-Locked `HN-Vocos`:** Eliminates the subtle hall/room echo from v0.1's unconstrained-phase Vocos head while keeping zero static on `r/s/x` fricatives.
- **3 Voices in 1 Model (`+1.5 KB` overhead):** Switch voices instantaneously via `voice_id: int64[1]` without reloading the ONNX session.
- **Zero-DC / Zero-Nyquist Spectral Mask:** Eliminates end-of-clip clicks/pops (`mean(DC) = 0.000000`, trailing silence peak `0.00001`).

## Files Included

| File | Voices | Params | Raw / Brotli | Native 1T RTF | Minimal-Pair Tone Acc | Notes |
|---|---:|---:|---:|---:|---:|---|
| **`onnx/tiny-voca-vi-v0.2.2-hnvocos-fp16.onnx`** | **3** | **4.77M** | `14.33 MB` / `12.39 MB` | **`0.0123`** (~80× RT) | as v0.2.1 (same weights) | **Recommended** · foreign words with stress, `stress` input |
| `onnx/tiny-voca-vi-v0.2.1-hnvocos-fp16.onnx` | **3** | **4.77M** | `14.32 MB` / `12.39 MB` | **`0.0125`** (~80× RT) | 79.2% (*Quỳnh Anh*) · 91.7% (*Trúc Ly*) · 75.0% (*Mai Anh*); wider test 86.6 / 84.0 / 79.5% | minimum pauses, clear *p*, `0.09%` CER (*Quỳnh Anh*) |
| `checkpoints/tiny-voca-vi-v0.2.1-hnvocos.pt` | 3 | 4.77M | PyTorch weights + config | — | — | v0.2 fine-tuned 8k steps (also the weights of v0.2.2) |
| `onnx/tiny-voca-vi-v0.2-hnvocos-fp16.onnx` | **3** | **4.77M** | `14.32 MB` / `12.37 MB` | **`0.0125`** (~80× RT) | **87.5%** (*Quỳnh Anh*) · **85.4%** (*Trúc Ly*) · **77.1%** (*Mai Anh*) | v0.2 · echo-free `HN-Vocos`, `0.16%` CER (*Quỳnh Anh*) |
| `checkpoints/tiny-voca-vi-v0.2-hnvocos-26k.pt` | 3 | 4.77M | PyTorch weights + config | — | — | Trained 26k steps on 12.11 h clean data |
| `onnx/tiny-voca-vi-v0.1-1024-fp16.onnx` | 1 | 4.66M | `13.84 MB` / `9.99 MB` | `0.0098` (~102× RT) | `79.2%` (*Mai Anh*) | Legacy v0.1 (`Vocos-1M`, `0.00%` CER) |
| `onnx/tiny-voca-vi-v0.1-512-fp16.onnx` | 1 | 4.55M | `10.46 MB` / `8.74 MB` | `0.0086` (~116× RT) | `70.8%` (*Mai Anh*) | Legacy v0.1 (2× overlap) |
| `checkpoints/tiny-voca-vi-v0.1-1024.pt` | 1 | 4.66M | PyTorch weights + config | — | — | Legacy v0.1 |
| `checkpoints/tiny-voca-vi-v0.1-512.pt` | 1 | 4.55M | PyTorch weights + config | — | — | Legacy v0.1 |

*(All ONNX files store large Linear/Conv weights and fixed STFT kernels in FP16 with `Cast(FP16→FP32)` compute—zero `DFT` ops, bit-exact determinism.)*

## Audio Samples (24 kHz, Free-Running E2E — v0.2)

| Voice (`voice_id`) | Sentence | Sample (`v0.2-hnvocos`) |
|---|---|---|
| **Quỳnh Anh** (`1`) | *Mỗi ngày em đều dậy sớm chạy bộ quanh hồ Hoàn Kiếm khoảng ba mươi phút.* | <audio controls src="https://huggingface.co/datmt24/tiny-voca-vi/resolve/main/samples/v0.2_quynh_anh_ho_hoan_kiem.wav"></audio> |
| **Trúc Ly** (`2`) | *Mỗi ngày em đều dậy sớm chạy bộ quanh hồ Hoàn Kiếm khoảng ba mươi phút.* | <audio controls src="https://huggingface.co/datmt24/tiny-voca-vi/resolve/main/samples/v0.2_truc_ly_ho_hoan_kiem.wav"></audio> |
| **Mai Anh** (`0`) | *Mỗi ngày em đều dậy sớm chạy bộ quanh hồ Hoàn Kiếm khoảng ba mươi phút.* | <audio controls src="https://huggingface.co/datmt24/tiny-voca-vi/resolve/main/samples/v0.2_mai_anh_ho_hoan_kiem.wav"></audio> |
| **Quỳnh Anh** (`1`) | *Hôm nay thời tiết Hà Nội mát mẻ, nắng nhẹ và không có mưa.* | <audio controls src="https://huggingface.co/datmt24/tiny-voca-vi/resolve/main/samples/v0.2_quynh_anh_ha_noi.wav"></audio> |
| **Trúc Ly** (`2`) | *Hôm nay thời tiết Hà Nội mát mẻ, nắng nhẹ và không có mưa.* | <audio controls src="https://huggingface.co/datmt24/tiny-voca-vi/resolve/main/samples/v0.2_truc_ly_ha_noi.wav"></audio> |
| **Quỳnh Anh** (`1`) | *Tiếng Việt có sáu thanh điệu rất rõ ràng, đặc biệt là thanh ngã và thanh nặng.* | <audio controls src="https://huggingface.co/datmt24/tiny-voca-vi/resolve/main/samples/v0.2_quynh_anh_sau_thanh.wav"></audio> |

## ONNX Interface (v0.2 to v0.2.2)

**Inputs:**
- `phoneme_ids`: `int64[1, T]`
- `tone_ids`: `int64[1, T]` (`0`=silence/punct, `1..6`=*ngang, huyền, sắc, hỏi, ngã, nặng*)
- `syl_pos`: `int64[1, T]` (`0`=onset, `1`=medial/nucleus, `2`=coda, `3`=non-syllabic)
- `voice_id`: `int64[1]` (`0`=*Mai Anh*, `1`=*Quỳnh Anh*, `2`=*Trúc Ly*)
- `speed`: `float32[1]` (`0.7–1.5`)
- `pitch_shift`: `float32[1]` (`-4.0` to `+4.0` semitones)
- `pause`: `float32[1]` (`0.5–2.0`, scales `tone_id == 0` durations and, from v0.2.1 on, the minimum pauses)
- `stress` (**v0.2.2 only, required**): `float32[1, T, 3]` = duration factor, pitch offset in semitones, energy offset per token; neutral is `(1, 0, 0)`. Built by `stress_features()` / `stressFeatures()`.

**Outputs:**
- `audio`: `float32[1, N * 256]` (24 kHz mono PCM)
- `durations`: `int64[1, T]` (frames per token)

## License & Attribution

**Apache-2.0**. Architecture and export conventions adapted from [`n4ze3m/tiny-voca`](https://github.com/n4ze3m/tiny-voca) (Apache-2.0); training audio distilled from [`pnnbao-ump/VieNeu-TTS-v3-Turbo`](https://huggingface.co/pnnbao-ump/VieNeu-TTS-v3-Turbo) (Apache-2.0, presets *Mai Anh*, *Quỳnh Anh*, *Trúc Ly*) over `wikimedia/wikipedia` `20231101.vi` (CC BY-SA 4.0); English readings derived from [CMUdict](https://github.com/cmusphinx/cmudict) (BSD-style); offline CTC alignment with `facebook/wav2vec2-lv-60-espeak-cv-ft` (Apache-2.0); filtering & eval with `vinai/PhoWhisper-medium` (BSD-3-Clause).