Text-to-Speech
ONNX
Polish
English
tts
polish
english
cpu
webassembly

Wilga

Wilga is a small text-to-speech model for Polish (8 voices) and English (3 voices). Each language model has 4.56M parameters, speaks at 24 kHz and runs on a CPU or in a web browser. Text is turned into phonemes by Wilga's own front end (numbers, dates, abbreviations and pronunciation rules), so no eSpeak and no GPU are needed.

  • Try it in the browser: Wilga demo (runs on your device)
  • Python: pip install wilga, then wilga.speak(text, language, voice) (PyPI)
  • Web: one JavaScript file, models load from this repository
  • ONNX: pl/model.onnx, en/model.onnx for any runtime

Voice samples

Every voice reads the same two texts. Try your own text in the browser demo.

Polish — (1) „Dzień dobry! Nazywam się Wilga. Spotkanie przeniesiono na 14:30, więc mamy jeszcze ok. 45 minut.”
(2) „Czy możesz mi powiedzieć, która jest godzina? Bo chyba się spóźnimy na pociąg!”

Voice (1) (2)
kobieta_dojrzala (default) mature woman
kobieta_ciepla woman, warm
kobieta_mloda young woman
dziewczyna_melancholijna young woman, melancholic
mezczyzna_baryton man, baritone
mezczyzna_mlody young man
mezczyzna_starszy older man
MC man (MC Speech)

English — (1) "Hello! My name is Wilga. The meeting moved to 3:30 pm, so we have about 45 minutes left."
(2) "Could you tell me what time it is? I think we're going to miss the train!"

Voice (1) (2)
hifi_92 (default) woman
hifi_6097 man
hifi_9017 man

Quick start

Python

pip install wilga
import wilga

tts = wilga.load("pl")                                    # downloads pl/model.onnx once (33 MB)
tts.save("Dzień dobry! Spotkanie jest o 14:30.", "dzien_dobry.wav", voice="kobieta_ciepla")

audio = wilga.speak("Hello there!", language="en", voice="hifi_92")   # float32 numpy array, 24 kHz
print(wilga.voices())                                     # {'pl': (...), 'en': (...)}

Dependencies: numpy, onnxruntime and huggingface_hub (no PyTorch). Text of any length is read sentence by sentence. speak and save also take speed (1.0 as predicted, larger is faster), pitch_shift (0.058 is about a semitone), pitch_range and sentence_gap (seconds of silence between sentences).

Command line

wilga "Dzień dobry! Spotkanie jest o 14:30." -o dzien_dobry.wav
wilga "Hello there!" --language en --voice hifi_6097 -o hello.wav
wilga --list-voices
echo "Tekst z pliku." | wilga -o out.wav

Without installing anything: uvx wilga "Dzień dobry!" -o dzien_dobry.wav.

Browser

Copy web/wilga.js into your site (the models and the WebAssembly front ends are fetched from this repository and cached by the browser):

<script type="module">
  import { loadWilga, toWav } from "./wilga.js";
  const tts = await loadWilga("pl");          // or "en"
  const audio = await tts.speak("Dzień dobry!", { voice: "kobieta_ciepla", speed: 1.0 });
  new Audio(URL.createObjectURL(toWav(audio, tts.sampleRate))).play();
</script>

web/worker.js runs the same off the main thread, and web/index.html is the demo page. Everything runs on the user's device; ONNX Runtime Web is loaded from jsDelivr.

ONNX directly

pl/model.onnx and en/model.onnx take phoneme ids and return the waveform. Get the ids with wilga.Wilga(language).phonemize(text) (Python) or tts.phonemize(text) (JavaScript).

Input Type Shape Meaning
tokens int64 [1, N] phoneme ids with the start and end tokens (symbols in pl/config.json, en/config.json)
stress int64 [1, N] 0 none, 1 primary, 2 secondary
voice int64 [1] index into voices in the language's config
speed, pitch_shift, pitch_range float32 [1] 1.0, 0.0, 1.0 = as predicted
express float32 [1, 2] zeros = the voice's typical delivery

Outputs: audio float32 [1, samples] at 24 kHz and durations int64 [1, N] (frames of 256 samples per token). One call reads one utterance of up to 512 tokens.

Voices

Language Voice Source
pl kobieta_dojrzala (default) mature woman synthetic, designed from a text description
pl kobieta_ciepla woman, warm synthetic, designed from a text description
pl kobieta_mloda young woman synthetic, designed from a text description
pl dziewczyna_melancholijna young woman, melancholic synthetic, designed from a text description
pl mezczyzna_baryton man, baritone synthetic, designed from a text description
pl mezczyzna_mlody young man synthetic, designed from a text description
pl mezczyzna_starszy older man synthetic, designed from a text description
pl MC man recorded: MC Speech (one speaker, CC0)
en hifi_92 (default) woman recorded: Hi-Fi TTS speaker 92 (LibriVox, CC BY 4.0)
en hifi_6097 man recorded: Hi-Fi TTS speaker 6097 (LibriVox, CC BY 4.0)
en hifi_9017 man recorded: Hi-Fi TTS speaker 9017 (LibriVox, CC BY 4.0)

The seven synthetic Polish voices do not belong to any real person: each was designed with VoxCPM2 from a written description of a voice, and VoxCPM2 then read training sentences in that voice. Samples of every voice are in samples/ (texts in samples/texts.json).

Results

Intelligibility is the word error rate (WER) of Whisper large-v3 transcripts of the synthesized speech. Each test set was chosen before the run and scored once.

Polish

Wilga same model with the eSpeak NG front end
WER, 1500 random sentences from Polish Wikipedia (spoken-form references) 9.05 % 11.96 %
same, sentences with Cyrillic or Greek words (41) 26.7 % 95.1 %
WER, 360 held-out sentences of the training voices 0.69 % 0.93 %
Words pronounced as in Wiktionary (30,386 test words) 99.08 % 98.31 %

The reference of the Wikipedia test is each sentence written out as it is read aloud (numbers, dates and abbreviations in words), so that reading "ur." as "urodzona" is not counted as an error. On Latin-script sentences most of the gain comes from the text normalizer; eSpeak NG given the same normalized text is as intelligible (8.66 % vs 8.60 %). UTMOS (predicted naturalness, 1-5) averages 3.68 over the eight voices.

English

Wilga tiny-voca (original English model) same model with eSpeak NG
WER, 1500 random sentences from English Wikipedia 3.86 % 4.00 % 4.55 %
UTMOS (predicted naturalness) 4.18 4.41
Heteronyms read as their context needs (record, live, read ...), audible in the speech 89.9 % 79.8 %

The English model is as intelligible as tiny-voca (difference -0.14 points, 95 % interval -0.39 to +0.11), but its predicted naturalness is lower and it is slower (see below).

Speed. Text to audio with the Python package, ONNX Runtime on 4 CPU threads: about 25x faster than real time in both languages, measured on a busy shared server. In headless Chromium (one thread) 10 s of Polish speech took 1.5 s. The front end takes about 1 ms per Polish and 10 ms per English sentence in Python, and 0.5 ms and 5 ms in WebAssembly.

Model

The architecture is a modified tiny-voca (Apache-2.0). A transformer encoder (4 blocks) reads phonemes with stress, a duration predictor gives each phoneme a length, and two frame-level transformers (2 and 5 blocks, 192 channels) predict pitch, voicing and energy and then the parameters of a source-filter synthesizer (pulse train and noise shaped by cepstral filters), without a neural vocoder. Changes from tiny-voca: harmonic envelope with 160 cepstral coefficients instead of 80, aperiodicity in 3 bands, a longer synthesis FFT, sentence-structure and expressiveness conditioning, random harmonic phase, and the Polish and English front ends. No weights come from tiny-voca or any other TTS model.

Training data

  • Polish: MC Speech (20.1 h, one speaker, CC0) and 18.3 h of VoxCPM2 speech in the seven designed voices (1.8 to 3.6 h each), from scratch.
  • English: Hi-Fi TTS "clean", speakers 92, 6097 and 9017 (43.6 h, CC BY 4.0, recordings from LibriVox), starting from the Polish model's weights.
  • Pretrained models were used only to label and evaluate data (forced alignment, Whisper, UTMOS, and local LLMs that wrote training labels for the numeral classifier and the list of English words in Polish text); none is part of Wilga.

Front ends. Polish: a normalizer with case and gender agreement (a 0.6M-parameter numeral classifier), pronunciation rules, tables generated from PoliMorf (prefix boundaries, inflected English loans) and Cyrillic and Greek transliteration. English: CMUdict, a letter-to-sound model for unknown words, heteronym rules and General American connected-speech rules. The Python and WebAssembly versions give the same phonemes.

Limitations

  • English: not more intelligible than tiny-voca, lower predicted naturalness, about 2.5 times slower.
  • Prosody is calm reading style; exclamations sound like statements.
  • Rare Polish sibilant contexts (an affricate at the very end of an utterance, initial "dż") are sometimes weak.
  • Scripts other than Latin, Cyrillic and Greek are skipped.

Licence and attribution

Apache-2.0 for the code, the models and the front-end data; see LICENSE and NOTICE. The English voices are trained on Hi-Fi TTS (Bakhturina et al., 2021, CC BY 4.0), made from LibriVox recordings by readers 92, 6097 and 9017. The Polish voice MC is trained on MC Speech (Czyżnikiewicz, 2022, CC0). The pronunciation dictionary CMUdict (Carnegie Mellon University, BSD-2-Clause) is included with its licence. Two tables of the Polish front end are derived from PoliMorf (Woliński, Miłkowski, Ogrodniczuk, Przepiórkowski, 2012; BSD-2-Clause).

Po polsku

Wilga to mały model syntezy mowy dla języka polskiego (8 głosów) i angielskiego (3 głosy), działający na CPU i w przeglądarce. Instalacja: pip install wilga, potem wilga "Dzień dobry!" -o dzien_dobry.wav albo wilga.load("pl").save(tekst, "plik.wav", voice="kobieta_ciepla"). Liczby, daty, godziny i skróty są czytane słownie, z odmianą („z 5 kotami” → „z pięcioma kotami”). Siedem polskich głosów jest syntetycznych (zaprojektowanych z opisu słownego w VoxCPM2), głos MC pochodzi z korpusu MC Speech.

Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Datasets used to train lion-ai/wilga

Space using lion-ai/wilga 1