File size: 9,504 Bytes
d25914e
bbd22fb
d25914e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cd2a221
d25914e
 
 
 
 
 
 
 
 
 
 
 
bbd22fb
d25914e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cb38021
d25914e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bbd22fb
 
d25914e
 
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
---
license: cc-by-4.0
language:
- fa
pipeline_tag: text-to-speech
tags:
- text-to-speech
- persian
- farsi
- onnx
- tiny-voca
- cpu
---

# tiny-ava

**tiny-ava** is a tiny **4.5M-parameter** Persian (Farsi) text-to-speech model trained from scratch on top of the [`tiny-voca`](https://github.com/n4ze3m/tiny-voca) architecture. Including the built-in waveform generator, the complete model is **~18 MB (PyTorch) / ~20 MB (ONNX)** and runs **38× faster than real time on 1 CPU thread** (**77× real time on 4 CPU threads**).

<audio controls src="https://huggingface.co/mehdi-hf/tiny-ava/resolve/main/samples/01_greeting.wav"></audio>

- **Try it in your browser (Live Demo):** https://huggingface.co/spaces/mehdi-hf/tiny-ava-demo
- **Code & release repo:** https://github.com/mallahyari/tiny-ava
- **Persian G2P frontends:** [`mehdi-hf/persian-g2p-tiny`](https://huggingface.co/mehdi-hf/persian-g2p-tiny) (16 MB, MIT) · `mehdi-hf/persian-g2p-0.6b` (596M, Apache-2.0)
- **Base architecture:** [`n4ze3m/tiny-voca`](https://github.com/n4ze3m/tiny-voca) (Apache-2.0)

| | |
|---|---|
| Parameters | 4,531,147 |
| Voice | `parisa` (Persian female) |
| Output | 24 kHz mono |
| Input | Persian IPA tokens (46 symbols) + 3-class stress/ezafe channel |
| CPU speed (acoustic + vocoder) | **38.5× real time** (1 thread) · **77.4× real time** (4 threads) |
| Pretrained weights in the model | None (trained from scratch) |
| License | CC BY 4.0 (free for all use, including commercial, with attribution) |

---

## Files

| File | Size | Contents |
|---|---:|---|
| `tiny-ava-parisa.pt` | 18.2 MB | PyTorch inference weights, float32 |
| `onnx/tiny-ava-parisa.onnx` | 20.4 MB | ONNX export, float32, opset 17 |
| `onnx/tiny-ava-parisa.json` | 761 B | Symbol table (46 symbols), voice map, and runtime metadata |
| `config.json` | 674 B | Model & acoustic DSP configuration |
| `samples/` | 2.5 MB | 12 sample 24 kHz WAVs |
| `charts/training_curves.png` | — | 104k-step training & validation curves |

SHA256:
- `tiny-ava-parisa.pt`: `698d43ea896eaa95bb6a444218097187fffb34b861710bd81a44a069eb4ab3d7`
- `onnx/tiny-ava-parisa.onnx`: `4e387b2f28a6d65916ed7c33ecdac4428135e9adfc13e1734b77592e6993a340`

---

## Samples (24 kHz, Parisa Voice)

| Category | Persian Text | Audio |
|---|---|---|
| Greeting & question | سلام، حال شما چطور است؟ امروز هوای تهران آفتابی است. | <audio controls preload="none" src="https://huggingface.co/mehdi-hf/tiny-ava/resolve/main/samples/01_greeting.wav"></audio> |
| Ezafe chain | نشست سران سیاسی کشورهای عضو به خوبی پیش رفت. | <audio controls preload="none" src="https://huggingface.co/mehdi-hf/tiny-ava/resolve/main/samples/02_ezafe_chain.wav"></audio> |
| Explicit kasra (`ـِ`) | بارانِ ریزی روی آسفالتِ خیسِ خیابان می‌بارد. | <audio controls preload="none" src="https://huggingface.co/mehdi-hf/tiny-ava/resolve/main/samples/03_ezafe_kasra.wav"></audio> |
| Homograph (`تست` → *tost*) | من هر روز صبح نان تست داغ با کره و عسل می‌خورم. | <audio controls preload="none" src="https://huggingface.co/mehdi-hf/tiny-ava/resolve/main/samples/04_homo_tost.wav"></audio> |
| Homograph (`گل` → *gol*) | گل قرمز زیبایی را روی میز گذاشت و لبخند زد. | <audio controls preload="none" src="https://huggingface.co/mehdi-hf/tiny-ava/resolve/main/samples/05_homo_gol.wav"></audio> |
| Homograph + diacritic (`گِل`) | کفش‌هایم بعد از باران پر از گِل و لای شد. | <audio controls preload="none" src="https://huggingface.co/mehdi-hf/tiny-ava/resolve/main/samples/06_homo_gel.wav"></audio> |
| Homograph (`مرد` → *mord*) | حیوان خانگی من دیروز در اثر گرمای شدید بیهوش شد و مرد. | <audio controls preload="none" src="https://huggingface.co/mehdi-hf/tiny-ava/resolve/main/samples/07_homo_mord.wav"></audio> |
| Question (`؟`) | آیا واقعاً فکر کردی که تولد تو را فراموش می‌کنم؟ | <audio controls preload="none" src="https://huggingface.co/mehdi-hf/tiny-ava/resolve/main/samples/08_question.wav"></audio> |
| Persian uvulars (`ق/غ/خ/ع`) | قصر قدیم در کنار غار خاموش و عمیق کوهستان قرار دارد. | <audio controls preload="none" src="https://huggingface.co/mehdi-hf/tiny-ava/resolve/main/samples/09_uvulars.wav"></audio> |
| Long sentence | توسعه مدل‌های کوچک هوش مصنوعی باعث می‌شود که فناوری تبدیل متن به گفتار بدون نیاز به سرور و اینترنت روی دستگاه‌های معمولی اجرا شود. | <audio controls preload="none" src="https://huggingface.co/mehdi-hf/tiny-ava/resolve/main/samples/10_long.wav"></audio> |
| Colloquial Persian | سلام، چطوری؟ دیگه باید برم، نمی‌تونم بیشتر بمونم. | <audio controls preload="none" src="https://huggingface.co/mehdi-hf/tiny-ava/resolve/main/samples/11_colloq_1.wav"></audio> |

---

## ONNX Interface

The ONNX graph (`onnx/tiny-ava-parisa.onnx`) takes Persian IPA token IDs and stress/ezafe values and directly outputs a 24 kHz waveform. Text-to-phoneme conversion runs outside the graph using either [`mehdi-hf/persian-g2p-tiny`](https://huggingface.co/mehdi-hf/persian-g2p-tiny) (16 MB) or `mehdi-hf/persian-g2p-0.6b` (596M), mapped to the 46-symbol table in `onnx/tiny-ava-parisa.json`.

### Inputs

| Input | Type | Shape | Meaning |
|---|---|---|---|
| `tokens` | `int64` | `[1, N]` | Persian IPA & punctuation IDs (`0..45`), wrapped with `<bos>` and `<eos>` |
| `stress` | `int64` | `[1, N]` | `0` unstressed, `1` word-final primary lexical stress, `2` explicit ezafe (`-e`/`-ye`) |
| `voice` | `int64` | `[1]` | `0` (`parisa`) |
| `speed` | `float32` | `[1]` | Speaking rate (`1.0` default; larger is faster) |
| `pitch_shift` | `float32` | `[1]` | Added to log F0 (`0.058` ≈ +1 semitone) |
| `pitch_range` | `float32` | `[1]` | Scales pitch movement around utterance mean (`1.0`–`1.1` recommended) |

### Outputs

| Output | Type | Shape | Meaning |
|---|---|---|---|
| `audio` | `float32` | `[1, samples]` | 24 kHz mono waveform (scale peak to ≤ `0.99` before 16-bit WAV export) |
| `durations` | `int64` | `[1, N]` | Predicted duration per token in frames (`256` samples = `10.67 ms` per frame) |

---

## Architecture

Built on the exact `tiny-voca` feed-forward transformer + complex-cepstrum source-filter architecture, adapted for Persian:

- **46-symbol Persian vocabulary:** 5 specials, 12 Persian/standard punctuation pause carriers (`،`, `.`, `؟`, `!`, `؛`, `:`, `«`, `»`, `(`, `)`, `—`, `…`), 23 consonants, and 6 vowels (`a, e, o, i, u, ɑ`).
- **Text encoder:** 4 Conformer-style RoPE blocks (`192` channels, `4` heads, kernel-7 depthwise conv, `640` FFN).
- **Duration & pause predictor:** Separate duration regression + binary pause-presence head for commas, periods, and word boundaries.
- **Prosody & acoustic stacks:** 2 frame blocks predicting log-F0, voicing, and energy + 5 frame blocks predicting harmonic & noise filter cepstra.
- **Source-filter waveform head (`25.9k` params):** Anti-aliased float64 harmonic pulse train + causal/anticausal complex-cepstrum filtering + 4-subframe noise branch (no neural vocoder required).

---

## Training & Evaluation

- **Training data:** 8,033 clean punctuated Parisa clips (**19.97 hours**, 24 kHz), annotated with `mehdi-hf/persian-g2p-0.6b` and offline CTC forced alignment (`facebook/wav2vec2-lv-60-espeak-cv-ft`, 99.73% QC acceptance, `88.6%` fricative-to-vowel voicing flip within 2 frames).
- **Training schedule:** 104,000 steps on 1× NVIDIA A100-80GB (~5.5 hours). Spectral + prosody losses for the first 8,000 steps, followed by multi-period and multi-resolution GAN discriminators (`--gan-ratio 0.7`, `--teacher-final 0`).

### Held-Out Test Evaluation (50 clips, `faster-whisper large-v3`, `language="fa"`)

| Model | Persian CER ↓ | Persian WER ↓ | CPU Speed (1 thread / 4 threads) |
|---|---:|---:|---:|
| **tiny-ava (`parisa`, 4.53M)** | **6.95%** *(0.85× teacher)* | **36.96%** *(0.92× teacher)* | **38.5× / 77.4× real time** |
| Teacher recordings (reference floor) | 8.20% | 40.22% | — |

![Training Curves](charts/training_curves.png)

---

## Limitations

- Single fixed female voice (`parisa`); no voice cloning.
- Pronunciation accuracy on rare homographs, numbers, and out-of-vocabulary loanwords depends on the upstream Persian G2P frontend (typing explicit `ـَ`, `ـِ`, `ـُ` diacritics lets you override pronunciation deterministically).
- Deterministic prosody: the same input text is always spoken with the same cadence.
- Utterance-level generation (not frame-streaming), though a 5-second Persian sentence synthesizes in ~65 ms on 4 CPU threads.

---

## License & Credits

- **Model Weights License:** **CC BY 4.0** (Creative Commons Attribution 4.0 International) — free for personal, research, and commercial use as long as you give credit.
- **Required Attribution:** Please include *"Powered by tiny-ava (Mehdi Allahyari / OncillaAI)"* with a link to [`mehdi-hf/tiny-ava`](https://huggingface.co/mehdi-hf/tiny-ava).
- **Architecture:** Based on [`n4ze3m/tiny-voca`](https://github.com/n4ze3m/tiny-voca) (Apache-2.0) by Muhammed Nazeem.
- **Offline Aligner (annotation only):** `facebook/wav2vec2-lv-60-espeak-cv-ft` (Apache-2.0).