tiny-voca Kiswahili (55k)
A 4.54M-parameter Swahili voice small enough to run offline on a low-end Android phone. 21.4 MB of ONNX, CPU only, no cloud: on a Redmi 9A (ARMv7, Android 11) it synthesises a sentence at RTF 0.16-0.21 in 71-75 MB of RAM.
It is trained from scratch with the tiny-voca recipe (Apache-2.0) by Nazeem (@n4ze3m), not fine-tuned from the English checkpoint. The same export is the voice of an offline reader for the Kenyan constitution, which highlights each spoken word from the model's own phoneme durations.
Sample (rendered by run_onnx.py from this exact ONNX file, voice index 0,
edge frames dropped and 0.25 s of silence appended):
sample-0.wavβ "Habari za asubuhi! Karibu Kenya." (2.74 s)sample-1.wavβ "Leo ni Jumatatu, tarehe kumi na tisa Novemba." (3.71 s)sample-2.wavβ "Bei ya unga ni shilingi elfu moja na mia tano." (3.73 s)
Model details
| Architecture | tiny-voca: source-filter vocoder with a duration head, 4 encoder layers |
| Parameters | 4.54M |
| Size | 21.4 MB ONNX (fp32); 18 MB PyTorch checkpoint |
| Sample rate | 24 kHz, hop 256 samples (10.67 ms per frame) |
| Input | phoneme ids from a 76-symbol inventory, one stress mark per token |
| Voices | 7 speaker ids (1-6, 8), all from WAXAL's Swahili speakers |
| Limit | 512 tokens per call; 3,000 frames (32 s) of audio |
| Training steps | 55,000 of a planned 104,000 |
Training
- Data:
swa_ttsfrom google/WaxalNLP (CC-BY-SA-4.0), 24 kHz resampled. 2,497 utterances (~13 h) from 7 speakers passed forced alignment (facebook/wav2vec2-lv-60-espeak-cv-ft, 55% gate); those are the training set. Splits hold out sentence text, not files - WAXAL reuses prompt sentences across recordings. - Text front end: a deterministic Swahili letter-to-phone transducer
(
chβtΚ,shβΚ,nyβn j,ng'βΕ,th/dhβΞΈ/Γ°, penultimate-syllable stress), so no grapheme model or attention is involved. Digits, money, dates and legal citations must be expanded to words before phonemisation; the model itself only ever sees phonemes. - Hardware: Kaggle free tier, T4 x2. Stopped at 55k steps when the stage-8 samples were clear to listen to, rather than spending the remaining GPU hours on a step count.
Interface
Inputs (dynamic length on axis 1):
| name | shape | dtype | meaning |
|---|---|---|---|
tokens |
[1, L] | int64 | phoneme ids, symbols.json |
stress |
[1, L] | int64 | 0 none, 1 primary, 2 secondary |
voice |
[1] | int64 | speaker index 0-6 |
speed |
[1] | float32 | duration divisor; 1.2 = 20% faster |
pitch_shift |
[1] | float32 | log-Hz offset, 0 = unchanged |
pitch_range |
[1] | float32 | prosody spread multiplier, 1 = unchanged |
Outputs:
| name | shape | meaning |
|---|---|---|
audio |
[1, N] | float32 mono at 24 kHz, peak below 0.5 |
durations |
[1, L] | frames per token; sum(durations) * 256 == N |
durations is the alignment: chunk i covers samples
[sum(durations[:i]) * 256, sum(durations[:i+1]) * 256). That is exact, not an
estimate, which is why word-level highlighting can come from the same forward
pass as the audio.
Voices
The voice input conditions every frame of a call; there is no speaker encoder
and the model cannot imitate an arbitrary speaker. The seven ids are seven
distinct WAXAL speakers, and the checkpoint's prosody still moves from
sentence to sentence at a fixed id.
Ten sentences of Psalms 23 rendered one at a time at speed 1.0 (this fp32
graph, librosa.pyin 60-400 Hz on voiced frames; median and range of the ten
per-sentence median F0):
voice |
WAXAL speaker | median F0 | per-sentence range | sd |
|---|---|---|---|---|
| 0 | 1 | 196 Hz | 184-207 Hz | 6.4 |
| 1 | 2 | 218 Hz | 196-229 Hz | 12.0 |
| 2 | 3 | 189 Hz | 170-202 Hz | 10.3 |
| 3 | 4 | 114 Hz | 105-137 Hz | 8.7 |
| 4 | 5 | 189 Hz | 179-201 Hz | 6.4 |
| 5 | 6 | 227 Hz | 216-236 Hz | 5.3 |
| 6 | 8 | 157 Hz | 139-171 Hz | 9.2 |
Two renders of the same sentence at the same id land within 2 Hz of each
other, so the 20-33 Hz spread is sentence-level prosody, not a change of
speaker. Voice 5 is the steadiest of the seven and voice 1 the least steady.
Setting pitch_range to 0.5 or 1.5 leaves the spread where it was (voice 1:
31.8 Hz becomes 32.7 and 34.8 Hz), and merging a verse's sentences into one
utterance does not help either (sd 11.4 -> 10.3 Hz). At 55k steps this is not
something a caller can normalise away, so if one id sounds uneven over a long
read, another id is worth trying. (An int8 quantisation of the same graph,
used by the Android reader, moves the medians by at most 2 Hz and keeps the
same ordering.)
Usage
pip install onnxruntime numpy
python run_onnx.py 0 out.wav
cases.json contains three sentences with pre-computed tokens and stress, so
the demo runs without the front end. For arbitrary text, use tiny-voca's
Swahili front end (TINY_VOCA_FRONTEND=sw) plus a Swahili verbalizer for
digits, dates, money and legal references, then feed the ids and stress arrays.
import numpy as np, onnxruntime as ort
sess = ort.InferenceSession("swahili.onnx", providers=["CPUExecutionProvider"])
audio, durations = sess.run(None, {
"tokens": np.array([tokens], dtype=np.int64),
"stress": np.array([stress], dtype=np.int64),
"voice": np.array([0], dtype=np.int64),
"speed": np.array([1.0], dtype=np.float32),
"pitch_shift": np.array([0.0], dtype=np.float32),
"pitch_range": np.array([1.0], dtype=np.float32),
})
The graph emits a leading <bos> and a trailing <eos> token around every
sentence. Their durations rows are the utterance-edge pauses, and on this
corpus those frames carry a burst rather than silence, so drop them before
normalising - see the first point under Known limitations.
Measured on a Redmi 9A (220233L2G, Android 11, armeabi-v7a)
ONNX Runtime 1.25.0, 4 threads, warm runs:
| sentence | audio | synthesis | RTF |
|---|---|---|---|
| Habari za asubuhi! Karibu Kenya. | 4.96 s | 798 ms | 0.161 |
| Leo ni Jumatatu, tarehe kumi na tisa Novemba. | 5.77 s | 1188 ms | 0.206 |
| Bei ya unga ni shilingi elfu moja na mia tano. | 5.70 s | 1167 ms | 0.205 |
audio is the raw graph output, edge frames included, so it is longer than the
corresponding sample wav.
Session creation 5.3 s, PSS 71-75 MB while synthesising. The same export reproduces the PyTorch duration counts and audio length sample for sample; waveforms correlate 0.94-0.98 with the desktop renderer, and two desktop runs of the same input differ by as much.
Known limitations
- Prototype voice. No native-speaker listening study and no WER/MOS evaluation yet. Expect uneven prosody on long sentences.
- Both edges of an utterance are pause frames, and on this corpus they are
not silent. The first and last token are
<bos>and<eos>; theirdurationsrows are the utterance-edge pauses. Those pauses come from clips cut at the quietest point near a sentence boundary, so they often contain leftover sound: of 582 sampled training clips 41% begin and 36% end with under 100 ms of silence. The graph reproduces the leftover as a burst of roughly 100 ms next to the first and last phoneme. On the four bundled sentences six of the eight edges peak at 0.095-0.355, the same order as the speech peak (0.24-0.35), and two are silent (0.003, 0.019); played raw, a sentence clicks at one or both ends. Drop the<bos>and<eos>frames (durations[0]anddurations[-1]) before normalising. The audio between them is untouched; the bundled samples andrun_onnx.pyare rendered that way. - A sentence ends with a long pause. Untrimmed it is ~1.9 s after the last
word, and a sentence-by-sentence read runs at about 70 wpm. Dropping the
<eos>frames removes most of it; keep about 0.25 s after the last word so the next sentence does not butt in. - Numerals and abbreviations are the caller's job. "2022" must arrive as "elfu mbili na ishirini na mbili"; the model cannot read digits.
- Read speech of seven speakers. No claim of dialect coverage, code switching, or emotional style. English is not supported.
- Not a cloning model. There is no speaker encoder; the seven ids are fixed.
Licence and provenance
- Weights: CC-BY-SA-4.0, inherited from WAXAL's share-alike licence. If you build on these weights, attribute the dataset and share your derivatives alike. The included PyTorch checkpoint is under the same terms.
- Training data: google/WaxalNLP
(
swa_tts, CC-BY-SA-4.0). No private or personal recordings were used, and no cloned voice is included; every voice here is a WAXAL speaker. - Code: tiny-voca by Nazeem, Apache-2.0 (https://github.com/n4ze3m/tiny-voca).
- The Swahili front end, verbalizer and on-device app were built for this release and are not part of tiny-voca upstream.
Files
| file | what |
|---|---|
swahili.onnx |
release graph, internal noise, 21.4 MB |
swahili-inference.pt |
PyTorch checkpoint (step 55,000) for fine-tuning |
metadata.json |
rate, hop, voices, limits, frontend identity |
recipe.json |
training recipe and data hashes |
symbols.json |
the 76 phoneme ids, index = id |
config.json |
upstream config (voices, vocab size) |
cases.json |
three demo sentences with token ids and stress |
run_onnx.py |
renders a case to 24 kHz wav, edge frames dropped |
sample-0/1/2.wav |
the three cases, rendered by this ONNX |
- Downloads last month
- 53