oddadmix's picture
New sample sentence 3
76286d8 verified
|
Raw History Blame Contribute Delete
11.9 kB
---
language: [ar]
license: apache-2.0
library_name: onnxruntime
pipeline_tag: text-to-speech
tags:
- text-to-speech
- tts
- speech-synthesis
- arabic
- msa
- modern-standard-arabic
- tiny-voca
- onnx
- cpu
- small-model
- multi-speaker
- trained-from-scratch
datasets: [oddadmix/tiny-voca-arabic-v2.1-dataset]
---
# tiny-voca-arabic v2.1
Version 2.1 of tiny-voca-arabic: a **4.5M-parameter** Modern Standard Arabic (فصحى) text-to-speech model with
**eight voices in four speaking styles** (assistant, news, story, promo; one female and one male voice each),
trained **from scratch** with the [tiny-voca](https://huggingface.co/n4ze3m/tiny-voca) architecture and an
Arabic phonetic front end. The waveform generator is included: text in, 24 kHz audio out, about 200× real time
on four CPU threads.
> **Based on [tiny-voca](https://huggingface.co/n4ze3m/tiny-voca) by Muhammed Nazeem ([@n4ze3m](https://huggingface.co/n4ze3m)).**
> This model uses the original tiny-voca architecture and training code
> ([github.com/n4ze3m/tiny-voca](https://github.com/n4ze3m/tiny-voca), Apache-2.0). No tiny-voca weights were reused:
> it was trained from scratch on Arabic data.
[Demo](https://huggingface.co/spaces/oddadmix/tiny-voca-arabic-v2) · [Dataset](https://huggingface.co/datasets/oddadmix/tiny-voca-arabic-v2.1-dataset) ·
Version 2: [oddadmix/tiny-voca-arabic-v2](https://huggingface.co/oddadmix/tiny-voca-arabic-v2) ·
Version 1 (two voices): [oddadmix/tiny-voca-arabic-v1](https://huggingface.co/oddadmix/tiny-voca-arabic-v1)
| | |
|---|---|
| Parameters | 4,534,411 (18 MB PyTorch, 21 MB ONNX) |
| Voices | 8 synthetic MSA voices, `voice` input 0–7 (table below) |
| Audio | 24 kHz mono |
| Training data | 89,569 utterances, 242 h after alignment checks (24–39 h per voice) |
| Training | 200k steps, about 5 h on one GPU |
| `voice` | Name | Style | Gender |
|---|---|---|---|
| 0 | `a000` | Assistant | female (the v0/v1 voice) |
| 1 | `am6` | Assistant | male (new; replaces v1's `ms06`) |
| 2 | `nf2` | News | female |
| 3 | `nm2` | News | male |
| 4 | `sf1` | Story | female |
| 5 | `sm3` | Story | male |
| 6 | `pf4` | Promo | female |
| 7 | `pm2` | Promo | male |
## What's new in v2.1
- A better `sf1` (story female) voice. v2's `sf1` had the least training data (21 h) and the noisiest output.
v2.1 adds 2,341 new story clips for it, and the alignment check now allows long phrase-final sounds (up to
~1.3 s instead of ~0.75 s; storytellers draw out the last sound of a phrase, and the old limit rejected 29% of
`sf1` clips). `sf1` now trains on 39 h.
- On the same 50 held-out `sf1` sentences: background-noise score (DNSMOS BAK) 3.57 → 3.79 (recordings 4.03),
overall quality score (P.808) 3.25 → 3.32 (recordings 3.46). Character error rate unchanged (0.3%, recordings 0.3%).
- The other seven voices are unchanged in quality (P.808 within 0.04 of v2, none lower) and accuracy (CER within
0.6 points of v2, still at or below the recordings' CER).
- Same architecture, inputs and voice order as v2: a drop-in replacement.
## What was new in v2
- Eight voices instead of two, covering four delivery styles: conversational assistant answers, steady news
reading, expressive story narration, and bright promotional reads.
- A new assistant male voice (`am6`) in place of `ms06`.
- Balanced data: every voice trains on a similar number of hours, so no voice dominates the shared network.
## Samples
| Text | a000 | am6 | nf2 | nm2 | sf1 | sm3 | pf4 | pm2 |
|---|---|---|---|---|---|---|---|---|
| مرحبًا بكم، هذا نموذج صغير لتحويل النص إلى كلام باللغة العربية الفصحى. | [▶](samples/a000-0.wav) | [▶](samples/am6-0.wav) | [▶](samples/nf2-0.wav) | [▶](samples/nm2-0.wav) | [▶](samples/sf1-0.wav) | [▶](samples/sm3-0.wav) | [▶](samples/pf4-0.wav) | [▶](samples/pm2-0.wav) |
| تقع مدينة القاهرة على ضفاف نهر النيل، وهي من أكبر المدن في العالم العربي. | [▶](samples/a000-1.wav) | [▶](samples/am6-1.wav) | [▶](samples/nf2-1.wav) | [▶](samples/nm2-1.wav) | [▶](samples/sf1-1.wav) | [▶](samples/sm3-1.wav) | [▶](samples/pf4-1.wav) | [▶](samples/pm2-1.wav) |
| هل يمكنك أن تخبرني عن حالة الطقس غدًا؟ أريد أن أخرج في نزهة مع أصدقائي. | [▶](samples/a000-2.wav) | [▶](samples/am6-2.wav) | [▶](samples/nf2-2.wav) | [▶](samples/nm2-2.wav) | [▶](samples/sf1-2.wav) | [▶](samples/sm3-2.wav) | [▶](samples/pf4-2.wav) | [▶](samples/pm2-2.wav) |
| يبلغ عدد سكان المدينة مليوني شخص ويشكّل الشباب أكثر من ثلث السكان. | [▶](samples/a000-3.wav) | [▶](samples/am6-3.wav) | [▶](samples/nf2-3.wav) | [▶](samples/nm2-3.wav) | [▶](samples/sf1-3.wav) | [▶](samples/sm3-3.wav) | [▶](samples/pf4-3.wav) | [▶](samples/pm2-3.wav) |
| العلم نور، والجهل ظلام. ومن جدّ وجد، ومن زرع حصد. | [▶](samples/a000-4.wav) | [▶](samples/am6-4.wav) | [▶](samples/nf2-4.wav) | [▶](samples/nm2-4.wav) | [▶](samples/sf1-4.wav) | [▶](samples/sm3-4.wav) | [▶](samples/pf4-4.wav) | [▶](samples/pm2-4.wav) |
## How it works
1. **Numbers** are read as MSA words (`code/numbers.py`).
2. **Diacritization** with [CATT](https://github.com/abjadai/catt) (encoder-decoder, Apache-2.0).
3. **Phonemes** from a rule-based MSA converter (`code/arabic_frontend.py`), 49 symbols:
sun-letter assimilation, hamzat al-wasl elision and helping vowels, long vowels shortened before
wasl, shadda as a doubled consonant, tanween, tāʾ marbūṭa (`t` inside a phrase, dropped at a pause),
pausal forms at punctuation, emphatic backing of /a/ next to ص ض ط ظ ق (and after خ غ ر), dark lām in
الله, and stress from syllable weight.
4. **Acoustic model + synthesizer**: the tiny-voca network predicts durations, pauses, pitch, voicing and
energy for the chosen voice, then a source-filter synthesizer makes the waveform. There is no separate
neural vocoder.
**Case endings.** Speakers often drop mid-sentence iʿrāb. While aligning the training data, each
mid-phrase case ending was kept or removed per clip according to which version the audio supports
(a CTC likelihood comparison), so the model learned from what was actually said.
## Evaluation
Whisper large-v3 transcripts of generated speech against the input text (diacritics and punctuation removed).
Held-out texts were not seen in training in either voice of a style; the new sentences appear in no split.
25 validation, 25 test and 8 new sentences per voice. CER, with the CER of the original recordings in brackets:
| Voice | Validation | Test | New sentences |
|---|---|---|---|
| `a000` assistant F | 0.2% (0.6%) | 1.6% (1.8%) | 0.3% |
| `am6` assistant M | 0.4% (0.5%) | 0.1% (0.2%) | 0.8% |
| `nf2` news F | 1.3% (1.7%) | 3.3% (3.5%) | 1.4% |
| `nm2` news M | 0.6% (0.5%) | 0.8% (1.0%) | 0.3% |
| `sf1` story F | 0.3% (0.3%) | 0.4% (0.5%) | 0.6% |
| `sm3` story M | 0.2% (0.5%) | 0.3% (0.3%) | 0.0% |
| `pf4` promo F | 2.5% (2.5%) | 1.3% (2.0%) | 0.0% |
| `pm2` promo M | 1.0% (0.9%) | 1.2% (1.5%) | 0.6% |
Quality score (DNSMOS P.808) gap between each voice's recordings and the model on the same held-out texts
(0 = same): `a000` 0.03, `am6` 0.01, `nf2` 0.18, `nm2` 0.23, `sf1` 0.14 (v2: 0.21), `sm3` 0.15, `pf4` 0.00, `pm2` 0.04.
Generated durations are within 5% of the recordings for every voice.
## Usage (ONNX Runtime)
```bash
pip install onnxruntime numpy soundfile tqdm
hf download oddadmix/tiny-voca-arabic-v2.1 --local-dir tiny-voca-arabic-v2.1
```
The front end in `code/` uses the CATT diacritizer; the
[demo Space](https://huggingface.co/spaces/oddadmix/tiny-voca-arabic-v2/tree/main) contains it ready to run
(`tiny_voca_ar/`, `catt_tashkeel/`). Minimal call:
```python
import numpy as np, onnxruntime as ort, soundfile as sf
from tiny_voca_ar.numbers import expand_numbers
from tiny_voca_ar.text import phonemize
session = ort.InferenceSession("tiny-voca-arabic-v2.1/onnx/model.onnx", providers=["CPUExecutionProvider"])
phones = phonemize(expand_numbers("مرحبًا بكم في عالم الذكاء الاصطناعي."))
one = lambda v: np.array([v], dtype=np.float32)
voice = 1 # 0 a000, 1 am6, 2 nf2, 3 nm2, 4 sf1, 5 sm3, 6 pf4, 7 pm2 (the order of "voices" in onnx/model.json)
audio, durations = session.run(None, {
"tokens": np.array([phones.ids], dtype=np.int64), "stress": np.array([phones.stress], dtype=np.int64),
"voice": np.array([voice], dtype=np.int64), "speed": one(1.0), "pitch_shift": one(0.0), "pitch_range": one(1.0)})
sf.write("hello.wav", audio[0], 24000)
```
Inputs: `tokens`/`stress` int64 `[1, N]`, `voice` int64 `[1]`, `speed` (1 = as predicted, larger is
faster), `pitch_shift` (added to log F0; 0.058 ≈ one semitone), `pitch_range` (scales intonation). Read
long text one sentence at a time (at most 500 phonemes / 32 s per call) and join the audio. Voices differ in loudness;
scale each result to the same peak level.
The PyTorch checkpoint `tiny-voca-arabic-v2.1.pt` loads with the tiny-voca code
(`tiny_voca.infer.load_model`) using the Arabic `text.py` / `arabic_frontend.py` from `code/`.
## Training
200k steps on one GPU. Steps 0–120k use the tiny-voca adversarial weight (`--gan-ratio 0.7`); steps 120k–200k
continue with `--gan-ratio 6`, the stronger adversarial term that made v1's voices sound less over-smoothed
("robotic").
## Limitations
- Eight voices, Modern Standard Arabic only; dialectal text is read with MSA rules.
- Pronunciation follows the automatic diacritization. When CATT picks the wrong reading, the model says it.
Add tashkeel yourself to fix a word.
- `sf1` (story female) improved over v2 but is still a little noisier than its recordings (quality-score gap 0.14).
- The news voices (`nf2`, `nm2`) have the largest quality-score gaps to their recordings (0.18–0.23).
- Latin script, emoji and symbols other than numbers and % are skipped.
## Training data
[oddadmix/tiny-voca-arabic-v2.1-dataset](https://huggingface.co/datasets/oddadmix/tiny-voca-arabic-v2.1-dataset):
99,948 clips (264 h) in the eight synthetic voices (the v2 data plus 2,341 `sf1` story clips); 89,569 training clips
passed the alignment quality checks.
All voices are synthetic; please tell listeners when audio they hear was generated.
## License
Apache-2.0.
## Changes from tiny-voca
The architecture is unchanged from tiny-voca 903f940: same network, synthesizer and losses, at the same size. The changes are:
- An Arabic front end that replaces the English phonemizer: CATT diacritization, MSA phoneme rules, a
49-symbol inventory and a number reader.
- Eight Arabic voices instead of the English F2/M2.
- A stronger adversarial term (`--gan-ratio 6`) for the last 80k steps.
- Aligner label mapping for the Arabic emphatics, and per-clip selection of spoken case endings during annotation.
- Training on 242 h of Arabic speech with packed memory-mapped features, plus an Arabic evaluation that uses
Whisper large-v3 CER.
## Credits
- **Original model, architecture and training code:** [tiny-voca](https://huggingface.co/n4ze3m/tiny-voca)
by Muhammed Nazeem ([@n4ze3m](https://huggingface.co/n4ze3m)), Apache-2.0
([code](https://github.com/n4ze3m/tiny-voca)).
- **Diacritizer:** [CATT](https://github.com/abjadai/catt) by Abjad AI, Apache-2.0.
## Citation
```bibtex
@software{oddadmix2026tinyvocaarabicv21,
author = {oddadmix},
title = {tiny-voca-arabic v2.1: a 4.5M-parameter eight-voice Modern Standard Arabic text-to-speech model},
year = {2026},
url = {https://huggingface.co/oddadmix/tiny-voca-arabic-v2.1},
license = {Apache-2.0}
}
```
Architecture and training code are from [tiny-voca](https://huggingface.co/n4ze3m/tiny-voca) by Muhammed Nazeem (see Credits).