Gapiring Nano v1 β Uzbek text-to-speech in 4.8M parameters
A very small Uzbek text-to-speech model for places with no GPU, no server and no connection: single-board
computers, kiosks and terminals, a web page, an app. One ONNX file of 30.7 MB, 4.8M parameters, 24 kHz speech, one
female voice (f1) in a neutral manner. Expect clear, intelligible speech with a plainer timbre than
Gapiring Edge, at a fraction of its size.
| Parameters | 4.8M (4,770,959) |
| File | nano.onnx, float32, 30.7 MB |
| Speed | about 50 times faster than real time on one CPU thread, over 100 times on four (Intel Core i5-13600KF, onnxruntime 1.23.2, 243 s of speech) |
| In a browser | a 5.7 s sentence in about 0.2 s (Chrome on the same desktop, WebAssembly, one thread) |
| Voice | f1 (female), neutral; a speed setting |
| Output | 24 kHz mono, one utterance per pass (not streamed inside an utterance) |
Measured on a desktop CPU only so far: no figures yet for phones or single-board computers.
Examples
| Text | Gapiring Nano |
|---|---|
| Markaziy terminal oldidagi avtoturargohda hozirda qirq ikkita bo'sh joy mavjud. Bir soatlik to'xtash narxi o'n besh ming so'm etib belgilangan. | |
| Operator bilan bog'lanish uchun kuting, siz navbatda ikki o'rinda turibsiz. |
Use it
Through the Gapiring libraries
Python (gapiring 0.2.0 and later) puts the text normaliser and the dictionary of English words in front of the model, so numbers, dates, money
and English words can be written as they are:
pip install gapiring
gapiring say "Uchrashuv 25-noyabr soat 14:30 da, to'lov Payme orqali, narxi 1 250 000 so'm." --model nano --out hello.wav
from gapiring import Gapiring
tts = Gapiring("nano") # Gapiring("nano", dictionary=False) leaves the dictionary out
tts.save("hello.wav", "Uchrashuv 25-noyabr soat 14:30 da, to'lov Payme orqali, narxi 1 250 000 so'm.")
for chunk in tts.stream(long_text, pace="slow"): # pace: "slow" or "fast"
play(chunk) # float32, 24 kHz mono
The dictionary (lexicon/en_uz.tsv, 565 thousand readings) adds about 3 s and about 400 MB of memory at load
(0.6 s and about 120 MB without it, on a desktop); on a small device, leave it out when the text has no English
words. Numbers and dates are read either way.
JavaScript (gapiring 0.2.0 and later; browser and Node, WebAssembly) has no normaliser and no dictionary: write
numbers as words and foreign words as they sound.
npm install gapiring
import { Gapiring } from "gapiring";
const tts = await Gapiring.load({ model: "nano" });
const audio = await tts.speak("Assalomu alaykum! Namuna kompaniyasining virtual yordamchisiman, sizga qanday yordam bera olaman?"); // Float32Array, 24 kHz mono
From the files of this repository
No normaliser here: numbers must be written as words (see Limits).
Python
pip install numpy onnxruntime soundfile
python runtime/nano_onnx.py --text "Assalomu alaykum! Namuna kompaniyasining virtual yordamchisiman, sizga qanday yordam bera olaman?" --out hello.wav
import sys; sys.path.insert(0, "runtime")
import soundfile as sf
from nano_onnx import Nano
tts = Nano(".") # the folder with nano.onnx and nano.json
sf.write("hello.wav", tts.speak("Assalomu alaykum! Namuna kompaniyasining virtual yordamchisiman, sizga qanday yordam bera olaman?"), tts.rate)
for chunk in tts.stream(long_text, speed=1.1):
play(chunk) # float32, 24 kHz mono, one piece per sentence group
In the browser
With onnxruntime-web loaded as the global ort (runtime/web/):
import { Nano, wav } from "./nano.js";
const tts = await Nano.load("./"); // a folder or a URL that holds nano.onnx and nano.json
const audio = await tts.speak("Assalomu alaykum!", { speed: 1.0 }); // Float32Array, 24 kHz mono
new Audio(URL.createObjectURL(new Blob([wav(audio, 24000)], { type: "audio/wav" }))).play();
The graph itself
Inputs: tokens int64 [1, N] (ids of the symbols listed in nano.json, between <bos> and <eos>, words
separated by <sp>), stress int64 [1, N] (zeros), voice int64 [1] (0), speed float32 [1] (1.0; larger is
faster), pitch_shift float32 [1] (0.0), pitch_range float32 [1] (1.0). Outputs: audio float32 [1, samples],
durations int64 [1, N]. Up to 512 tokens and 32 s per pass; the runtimes cut longer texts into sentence groups.
Limits
- The model itself reads Uzbek written in Latin letters: numbers, dates and amounts as words, and English
spelling is not read as English. The Python library puts a text normaliser and the dictionary of readings
(
lexicon/en_uz.tsv) in front of it; in JavaScript and with the bare files, do that yourself. - One voice and one neutral manner: no roles, manners or emotions (Gapiring Edge and Large have them).
- A whole utterance is made in one pass, so sound starts when that pass ends.
Licence
Open source, free for any use, commercial use included. The code is under the MIT licence; the model file and the dictionary are
under CC BY 4.0 (credit: Gapiring Nano by Gapi). The model design and parts of the runtime come from
tiny-voca (Apache-2.0, LICENSE-tiny-voca). Full text: LICENSE.