Nano Urdu TTS
A 443,402-parameter Urdu text-to-speech model whose int8 weights are about 502 KB. It runs on a CPU through the sanoTTS C runtime, and in a browser as WebAssembly built from the same C code (verified to match the C output to about 1e-7).
Try it in your browser: https://nano-urdu-tts.vercel.app/ (the voice and its pronunciation engine run on your device; source: https://github.com/Zafar205/nano-urdu-tts)
Non-commercial research release (CC BY-NC 4.0). Intelligibility matches the 36M-parameter model it learned from, but it is not as clear as a human voice (see the evaluation below).
In one paragraph
Nano Urdu is a distilled voice. Meta's MMS-TTS Urdu (36,288,432 parameters) read about 20,000 sentences from
the UrduTTS corpus (19,796 survived alignment), and three small networks (duration, acoustic, waveform decoder) were trained to reproduce
that voice from phonemes. The network designs, training tools and int8 C runtime come from sanoTTS; the two
front networks were trained from scratch at new sizes and the decoder started from sanoTTS's published
heart-nano decoder weights, then was retrained on the Urdu teacher audio with GAN losses.
Audio samples
Sentences the model never saw in training, spoken by the int8 Nano Urdu model (443k parameters).
| Text | Nano Urdu (int8) |
|---|---|
| آج موسم بہت اچھا ہے، چلو باہر چلتے ہیں۔ | |
| پاکستان کا دارالحکومت اسلام آباد ہے۔ | |
| مجھے چائے بہت پسند ہے لیکن کافی نہیں۔ | |
| براہ کرم دروازہ بند کر دیں۔ | |
| یہ کمپیوٹر پروگرام موبائل فون پر بھی بہت تیزی سے چلتا ہے۔ |
More clips (float model, long news text, one-word input) are in samples/unseen-sentences/.
Evaluation: intelligibility measured with Whisper large-v3
Each system speaks the same held-out sentences, OpenAI Whisper large-v3 transcribes the audio back to Urdu text
(greedy decoding, language forced to Urdu), and the transcript is scored against the sentence that was spoken.
The notebook that produced these numbers is in notebooks/Nano_Urdu_Eval_Kaggle.ipynb; all transcripts and scores
are in evaluation/results.csv.
| System | Sentences | WER (95% interval) | CER | Perfectly transcribed |
|---|---|---|---|---|
| Human recordings (corpus) | 200 | 2.4% (1.8–3.1) | 0.9% | 76.5% |
| Teacher: MMS-TTS Urdu | 200 | 10.9% (9.4–12.4) | 4.5% | 27.5% |
| Nano Urdu (this model, int8) | 200 | 10.5% (9.3–11.7) | 4.3% | 23.0% |
Test set "corpus": 200 sentences from the test split of kaab4321/UrduTTS, which the model never trained on.
Lower is better. The human row is the floor: it shows how well Whisper itself can do on this text.
| System | Sentences | WER (95% interval) | CER | Perfectly transcribed |
|---|---|---|---|---|
| Teacher: MMS-TTS Urdu | 47 | 12.4% (8.2–17.9) | 5.0% | 38.3% |
| Nano Urdu (this model, int8) | 47 | 8.7% (5.6–12.4) | 4.7% | 48.9% |
Test set "everyday": 47 sentences written for this evaluation (greetings, facts, numbers, English loanwords, short phrases, long sentences). No human recordings exist for these.
What the numbers say
- Nano Urdu is statistically indistinguishable from its teacher. On the corpus sentences, nano minus teacher is -0.4 WER points (95% interval -1.7 to +0.8, which includes zero).
- It is not human-level: nano is +8.1 points above real recordings (interval +6.8 to +9.3). That gap is inherited from the teacher.
- On the small everyday set nano scores lower than the teacher, but the difference (-3.8 points, interval -8.7 to +0.7) is not significant. Do not read it as nano beating the teacher.
- Errors are mostly substitutions (a mispronounced sound turns one word into another), not skipped or invented words.
- Speed: median real-time factor 0.029 (about 35x faster than real time) on one Kaggle CPU thread.
How to read WER here. This is an automatic measure: Whisper's own mistakes are included, and it is not the error rate a human listener would report. Scores are corpus-level (total errors over total reference words). Both sides are cleaned the same way before comparing (numbers spelled out in Urdu words, punctuation and vowel marks removed, Arabic look-alike letters mapped to Urdu forms). CER ignores spaces because Urdu word spacing is inconsistent. Intervals are 95% bootstrap intervals over sentences. The corpus sentences are unseen but are the same kind of text as the training data (largely literary and religious prose), so everyday speech may score differently; the everyday set is small (47 sentences).
Typical failures (from evaluation/worst/): a rare sound is replaced by a similar one, e.g. روح heard as لو,
آہ as آگ, ٹھیک as کی. This is consistent with the acoustic model blurring some rarer sounds, but that has not been tested.
Export check: the int8 parity gate did not pass
The sanoTTS runtime's own gate compares the int8 C output with the float PyTorch model on held-out clips and requires
waveform correlation of at least 0.98. This model fails it: mean 0.944, minimum 0.913, and
7 of 8 clips are below 0.98 (int8/parity-check.txt). The intelligibility numbers above were measured on the
int8 C runtime, i.e. the files that ship, so they already include this effect. The float checkpoints are in checkpoints/
if you want to compare.
Files
| Path | What |
|---|---|
config.json |
Release version, sample rate, parameter count, and weight file paths |
model.safetensors |
The float32 weights of all three networks in one file (1.8 MB, 443,402 parameters): tensors are prefixed duration., acoustic., decoder. (the decoder generator only). The metadata holds each network's configuration and the 88-phone map. Load it with code/nano_safetensors.py |
int8/ |
The deployable package: front_q8.bin (278,224 B), model_q8.bin (235,936 B), nano_q8_meta.h, phones.json (88 phones), export-report.json, parity-check.txt |
checkpoints/ |
Float PyTorch checkpoints (duration 36,196 / acoustic 201,084 / decoder 206,122 parameters), training config and reports. decoder.pt also holds the training-only GAN discriminators |
evaluation/ |
Whisper large-v3 results: summary.json, results.csv (every transcript and score), wer-cer.png, worst/ (audio of the hardest sentences for every system) |
samples/ |
unseen-sentences/: 12 new sentences spoken by the teacher, the float model and the int8 model. held-out-compare/: held-out corpus clips through each stage. urdu-script-example.wav |
notebooks/ |
Nano_Urdu_Kaggle.ipynb (training, v7) and Nano_Urdu_Eval_Kaggle.ipynb (this evaluation). Each is self-contained |
code/ |
Urdu text front end (urdu_frontend.py, phones.py), renderer (speak.py), training and export scripts |
Usage
The model takes phonemes, produced by eSpeak NG (espeak-ng -v ur), and the
text front end in code/ handles normalization, number expansion and phone mapping.
hf download zafar205/nano-urdu-tts-worlds-smallest-urdu-tts-450k-parameters \
--include 'config.json' 'model.safetensors' 'code/*' 'int8/*' \
--local-dir nano-urdu
cd nano-urdu/code
pip install -r requirements.txt
make upstream # fetches the pinned sanoTTS C runtime (needs git and a C compiler)
# eSpeak NG must be installed: brew install espeak-ng or apt install espeak-ng
python urdu_frontend.py ../int8 'آج موسم بہت اچھا ہے، چلو باہر چلتے ہیں۔' out.wav
Load the weights from model.safetensors
model.safetensors is the float version of the same trained model. code/nano_safetensors.py rebuilds the three
networks from it (it needs make upstream and the packages above), and speak() runs them end to end:
import nano_safetensors as ns # from the code/ folder, after `make upstream`
voice = ns.load("../model.safetensors") # voice.duration, .acoustic, .decoder (PyTorch), .phones
audio = ns.speak(voice, "پاکستان کا دارالحکومت اسلام آباد ہے۔") # float32 numpy, 24 kHz
python nano_safetensors.py check ../model.safetensors # what the file contains
python nano_safetensors.py say ../model.safetensors 'السلام علیکم' out.wav
The tensors in this file were checked bit-for-bit against the training checkpoints in checkpoints/, and audio made from it
is identical to audio made from those checkpoints. speak() handles about one sentence (up to 190 phones) per call. The
evaluation above used the int8 runtime, not these float weights.
Numbers (25, ۲۵, ٢٥) are read as Urdu words. Write dates, times and ranges out in words. English letters are not supported.
Sounds eSpeak produces that the voice never saw in training (mainly in loanwords) are mapped to the nearest known sound.
Training details
- Teacher data: MMS-TTS Urdu (
facebook/mms-tts-urd-script_arabic), noise scale 0.1, reading UrduTTS sentences. Only the corpus text is used for training; its human recordings are not (they appear only as the "human" row above). - Alignment: a Wav2Vec2 phoneme aligner (training only) times each sound; silences between words become
|tokens. About 19,796 of 20,000 clips were kept (checkpoints/alignment-skips-train.json). - Configured steps: duration 20,000, acoustic 100,000, decoder 30,000 + 30,000 with GAN discriminators (multi-period and multi-resolution) and spectral, phase and feature-matching losses. Decoder training was time-boxed to an 11-hour budget; the number of steps actually reached is not recorded in the checkpoint.
- Full configuration:
checkpoints/run-config.json; everything is reproducible fromnotebooks/Nano_Urdu_Kaggle.ipynb.
Limitations
- One voice; Urdu script only (no Roman Urdu, no mixed-language text); very long text should be split into sentences.
- Not natural enough to pass for a person; clarity is capped by the teacher.
- The UrduTTS corpus can contain several speakers, but only its text is used here. The voice is a single speaker: the teacher's.
- Evaluation covers intelligibility only. There is no listener study and no naturalness score.
License and credits
The weights are released under CC BY-NC 4.0 (non-commercial use only, attribution required), because they were trained on audio from MMS-TTS Urdu (CC BY-NC 4.0) and on sentences from the UrduTTS corpus (CC BY-NC 4.0).
- MMS-TTS Urdu by Meta, the teacher voice: https://huggingface.co/facebook/mms-tts-urd-script_arabic
- UrduTTS corpus by kaab4321: https://huggingface.co/datasets/kaab4321/UrduTTS
- sanoTTS by Ampixa: https://github.com/Ampixa/sanoTTS. Its C runtime is MIT; its tooling (which the training code
in
code/and the notebooks adapt) is GPL-3.0-or-later. The decoder was initialized from its publishedheart-nanoweights, and the upstream README does not state separate terms for those weights, so check upstream if that matters to you. - eSpeak NG (GPL-3.0-or-later) provides the pronunciation front end and is not bundled in this repository.
- Whisper large-v3 (OpenAI, MIT) was used only as an evaluation tool.
- Downloads last month
- 76