File size: 14,445 Bytes
300e307
 
95a5c12
e34095e
95a5c12
300e307
c4be26e
c5a0413
0c8ca44
c4be26e
e34095e
c4be26e
 
95a5c12
c4be26e
 
 
 
 
 
 
 
 
 
 
 
 
300e307
 
c4be26e
300e307
c4be26e
 
5a178d2
c4be26e
3c2c15e
c4be26e
 
 
 
 
 
 
 
 
5a178d2
c4be26e
 
5a178d2
c4be26e
6768c5d
3c2c15e
7326f54
c4be26e
 
 
 
 
 
7e5e951
c4be26e
300e307
c4be26e
 
 
 
 
7326f54
c4be26e
7e5e951
c4be26e
7e5e951
c4be26e
 
3c2c15e
c4be26e
 
300e307
c4be26e
300e307
95a5c12
e34095e
3c2c15e
2718d61
3cbb4ed
e34095e
 
 
 
 
 
c4be26e
3cbb4ed
c4be26e
e34095e
95a5c12
f712b8a
c4be26e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e34095e
3c2c15e
c4be26e
 
 
e34095e
c4be26e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e34095e
 
 
3cbb4ed
 
e34095e
 
 
 
 
 
 
 
 
3cbb4ed
e34095e
 
 
3cbb4ed
 
e34095e
 
 
c4be26e
3cbb4ed
e34095e
3c2c15e
c4be26e
 
 
 
 
 
 
e34095e
 
 
c4be26e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ba0428a
3c2c15e
c4be26e
 
e34095e
95a5c12
f712b8a
e34095e
 
 
 
3cbb4ed
 
e34095e
2718d61
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
---
language:
- sk
- en
license: cc-by-sa-4.0
pipeline_tag: text-to-speech
library_name: onnx
tags:
- text-to-speech
- tts
- slovak
- slovenčina
- english
- onnx
- onnxruntime
- onnxruntime-web
- on-device
- offline
- browser
- flow-matching
datasets:
- streams-sro/trepal
- vsisik/voice-dataset-lili
- google/fleurs
- sarulab-speech/commonvoice22_sidon
- MikhailT/hifi-tts
- eustlb/dailytalk
---

# Regulus: Slovak and English text-to-speech for your app

**Small, open text-to-speech that runs on your own hardware, with no API key, no per-character fees and no audio
leaving the device.** Natural Slovak with a full Slovak text frontend, and English with two steady voices.

- **Slovak done properly:** numbers, dates, times, money and percentages are read with the right case endings
  ("Dňa 3. mája o 14:30 prišlo 250 ľudí": o štrnásť tridsať, dvestopäťdesiat). Abbreviations, voicing assimilation across words, stress, questions and
  pauses are handled, and ~360 foreign names are read the way Slovaks say them (Biden, Washingtone, Musk).
  About **1.3 % character error rate** on unseen sentences.
- **English:** two voices (studio audiobook woman, conversational man), a fast CPU mode about 9x faster than real
  time, and numbers, money and units written out.
- **Runs anywhere:** a 42 M-parameter acoustic model plus a 14 M vocoder, exported to ONNX. It runs with
  `onnxruntime` on a server or laptop CPU and with `onnxruntime-web` in the browser (WebGPU or WebAssembly). The
  Slovak package needs only `numpy`, `onnxruntime` and `soundfile`.
- **Streams sentence by sentence**, so playback can start while the rest of a long text is still being generated.
- **Open weights** (CC BY-SA 4.0), open code, measured quality, and a demo you can try first.

**[Try it in your browser →](https://huggingface.co/spaces/mmmhusto/TTS-English-demo)** (English and Slovak,
generated locally on your device).

## Listen

Slovak, voice `sk_a` (Regulus v5.1, the default settings below):

| Text | Audio |
|---|---|
| Dňa 3. mája o 14:30 prišlo na námestie vyše 250 ľudí. Vstupné stálo 12,50 €, deti mali vstup zadarmo. | <audio controls preload="none" src="https://huggingface.co/mmmhusto/Regulus/resolve/main/samples/sk_a_spravy.wav"></audio> |
| Starý maják stál na útese už dvesto rokov. Za jasných nocí bolo jeho svetlo vidieť na tridsať kilometrov. ... | <audio controls preload="none" src="https://huggingface.co/mmmhusto/Regulus/resolve/main/samples/sk_a_pribeh.wav"></audio> |
| Prezident Biden sa vo Washingtone stretol s Elonom Muskom. Teta nám v nedeľu upiekla teplé koláče. | <audio controls preload="none" src="https://huggingface.co/mmmhusto/Regulus/resolve/main/samples/sk_a_mena.wav"></audio> |
| Prídeš zajtra na obed? Kto ti to povedal? To je skvelá správa! | <audio controls preload="none" src="https://huggingface.co/mmmhusto/Regulus/resolve/main/samples/sk_a_otazky.wav"></audio> |

English (Regulus v2.1):

| | `en_hifi_92_clean` (default) | `en_dt_0` |
|---|---|---|
| Reading a story | <audio controls preload="none" src="https://huggingface.co/mmmhusto/Regulus/resolve/v2.1/samples/story_92.wav"></audio> | <audio controls preload="none" src="https://huggingface.co/mmmhusto/Regulus/resolve/v2.1/samples/story_dt0.wav"></audio> |
| Numbers: "Dr. Smith will see you at 9:30 on March 3rd; the visit costs $45.50 ..." | <audio controls preload="none" src="https://huggingface.co/mmmhusto/Regulus/resolve/v2.1/samples/numbers_92.wav"></audio> | |
| Fast mode on a CPU (2-step decoder + Vocos) | <audio controls preload="none" src="https://huggingface.co/mmmhusto/Regulus/resolve/v2.1/samples/fast_vocos_story_92.wav"></audio> | |

## Which version for your app

One repository, one model line; every release has a tag. Pick the tag for your language:

| You need | Use | Voices | Package |
|---|---|---|---|
| **Slovak** | **`v5.1`** (this page, `main`) | `sk_a`: man, natural reading voice | `tts_slovak` (onnxruntime) |
| **English** | **`v2.1`** | `en_hifi_92_clean` (woman, studio), `en_dt_0` (man, conversational) | `tts_english` (PyTorch) |
| English and Slovak in one app | both tags side by side | as above | both packages, ~0.5 GB of files together |

## Quick start: Slovak

```sh
pip install numpy onnxruntime soundfile huggingface_hub
hf download mmmhusto/Regulus --revision v5.1 --local-dir Regulus
cd Regulus
python -m tts_slovak "Dňa 3. mája o 14:30 prišlo 250 ľudí. Prečo práve tam?" vystup.wav
```

```python
from tts_slovak import SlovakTTS

tts = SlovakTTS.from_pretrained(".")                 # the downloaded folder
wav = tts("Dobrý deň, ako sa máte?")                # float32 numpy array, 24 kHz, mono
tts.save("Vlak odchádza o 7:45 z druhej koľaje.", "vlak.wav")
for chunk in tts.stream("Prvá veta. Druhá veta."):   # one chunk per sentence: play the first while the rest renders
    ...
```

`SlovakTTS.from_pretrained()` without a path downloads only what the package needs (`web/`, ~110 MB).

## Quick start: English

```sh
pip install torch numpy soundfile huggingface_hub safetensors g2p_en
python -c "from g2p_en import G2p; G2p()"   # fetches g2p_en's NLTK data once
```

```python
from huggingface_hub import snapshot_download
import sys, soundfile as sf

path = snapshot_download("mmmhusto/Regulus", revision="v2.1")
sys.path.insert(0, path)
from tts_english import TTS, SAMPLE_RATE

tts = TTS.from_pretrained(path, vocoder="vocos", fast=True)   # fast on a CPU, nothing else to install
wav = tts("Your order has shipped and should arrive on Friday.", voice="en_hifi_92_clean")
sf.write("out.wav", wav, SAMPLE_RATE)
```

For the best English sound use the BigVGAN vocoder (`git clone https://github.com/NVIDIA/BigVGAN`, then
`TTS.from_pretrained(path, bigvgan_dir="BigVGAN")`). The [v2.1 page](https://huggingface.co/mmmhusto/Regulus/tree/v2.1)
covers styles, long texts, voice cloning and adding your own voice from 5 minutes of speech.

## In the browser and on devices

The Slovak model in `web/` is ready for [onnxruntime-web](https://onnxruntime.ai/docs/tutorials/web/):
`text.onnx` (text encoder and durations), `decoder.onnx` (flow-matching decoder), `bigvgan.onnx` (vocoder) and
`voices.json` (voice vector, symbol table, delivery settings). The
[demo Space](https://huggingface.co/spaces/mmmhusto/TTS-English-demo/tree/main) is a complete, static web app that
runs both languages in the browser. Copy it as a starting point:

- `tts.js`: the model on onnxruntime-web (WebGPU, or WebAssembly where WebGPU is missing).
- `sk-frontend.js`: the Slovak text frontend, the same Python code as `tts_slovak/frontend`, run with Pyodide.
- `app.js`: loading, progress, sentence-by-sentence playback, a lighter path for iPhones.

The same ONNX files run in any onnxruntime binding (Python, C/C++, C#, Java, JavaScript, mobile). `tts_slovak/__init__.py`
(a few hundred lines of numpy) is the reference for the steps between the graphs.

## Quality and speed

**Slovak, v5.0 / v5.1:** 105 sentences the model never trained on, read by `tts_slovak` (10 decoder steps). 64 of them are
dense in ť ď ň ľ and in words read hard (ten, jeden, mladé, systém); 41 are FLEURS and TrePal test sentences.
Scored with the Slovak Whisper `kinit/whisper-large-v3-turbo-sk` (character error rate), Whisper language
identification and TorchAudio SQUIM (PESQ estimate, 1-4.5):

| Voice | Character errors | P(Slovak) | PESQ |
|---|---|---|---|
| `sk_a` | 1.30 % | 0.98 | 3.91 |

Most of these errors are Whisper writing numbers as digits ("desať" -> 10) and the Indian names of one sentence.
The PESQ estimate equals that of the speaker's own recordings (3.91). Speed: 1.7 s of computing per second of speech
on an Apple M1 Pro CPU (onnxruntime, measured on a busy machine). With streaming, the first sentence plays after its
own time. A GPU (`SlovakTTS(path, providers=["CUDAExecutionProvider"])`) or fewer decoder steps (`steps=4`) go
faster.

**English, v2.1:** 64 sentences, word errors by Whisper small.en, speed on an Apple M1 Pro CPU:

| Mode | Word errors | PESQ | CPU time / speech time |
|---|---|---|---|
| full decoder + BigVGAN (best sound) | 1.9 % | 3.87 | 1.73 |
| fast decoder + Vocos (fastest) | 1.5 % | 2.88 | 0.11 |

## The Slovak voice and text frontend

| Voice | Sound | Built from |
|---|---|---|
| `sk_a` | man, natural reading voice | one anonymous Slovak Mozilla Common Voice contributor (3 h, CC0) |

`sk_a` is the voice of a real, anonymous person who gave their recordings to Mozilla Common Voice under CC0. Please do
not use it to impersonate anyone or to try to identify the speaker, and tell your users that the speech is
synthetic. The three synthetic Slovak voices of earlier releases (sk_f3, sk_f2, sk_m1) remain in `v4.0`.

**Text frontend** (`tts_slovak/frontend`, pure Python, no dependencies) does the following:

- reads numbers, dates, times, money and percentages with Slovak declension;
- expands common abbreviations;
- converts letters to sounds with voicing assimilation across words, and marks stress;
- tells sentence types apart (statement, yes/no question, wh-question, exclamation) and sets pause levels;
- respells about 360 foreign (mostly English) names, places, brands and words the way Slovaks say them, with Slovak
  case endings (Biden -> bajden, Washingtone -> vošingtone);
- keeps d t n l hard where Slovak does: ten, tento, tie, jeden, vtedy, teda, the adjective endings -é, -ého, -ému,
  -ej (mladé, celej) and ~330 loanword stems (systém, problém, partner).

**Delivery:** `sk_a` keeps the timing its speaker has, with short comma pauses, a silent lead-in and a silent
sentence end. It also gets a short j after ť ď ň before e (ťeta -> ť j e t a, the j at 0.7 of its length): its
speaker softens them weakly, and the model learnt that. The setting is `soft_glide` in `web/voices.json`.

### PyTorch

`model.safetensors` + `config.json` hold the acoustic model (41.8 M parameters) for research or fine-tuning, and
`vocoder.safetensors` the vocoder; the code is `tts_slovak/model.py`:

```python
import json, torch
from safetensors.torch import load_file
from tts_slovak.model import SkttsV2, natural_sk

cfg = json.load(open("config.json"))
model = SkttsV2(len(cfg["symbols"]), len(cfg["voices"]), cfg["mel_mean"], cfg["mel_std"], cfg=cfg["model"]).eval()
model.load_state_dict(load_file("model.safetensors"))
kw = {**natural_sk(cfg["symbols"], cfg["model"]), "eq_gain": None, **cfg["delivery"]}  # the voice's own timing
# ids: tts_slovak.SlovakTTS.ids(tokens of the frontend); spks: index into cfg["voices"]
```

The vocoder is NVIDIA's `nvidia/bigvgan_base_24khz_100band` (MIT) fine-tuned on this voice; `web/bigvgan.onnx` is
its export.

## Known limits

- Slovak yes/no questions end with a falling melody, as in most of the training speech (Slovak speakers often rise).
- 24 kHz audio. Foreign names outside the list are read with Slovak rules.
- Very long sentences without punctuation are read in one piece.
- One Slovak voice; English and Slovak are separate releases (`v2.1`, `v5.1`).

## License

The weights are **CC BY-SA 4.0**, inherited from DailyTalk in the English base model. You may use them, also
commercially, if you credit "Regulus by mmmhusto" and the datasets below. Models you derive from these weights
must be shared under the same license. Please read the license text for your own case. The code in `tts_slovak/`
comes with the weights under the same terms.

## How it was made

The English base model (v1.0, a 42 M transformer encoder + flow-matching DiT decoder with a duration flow) was
trained from scratch. It then learnt Slovak with a shared symbol table (English ids first, then `sk:` phonemes):

- data: TrePal (166 speakers, at most 1.5 h each), Lili and FLEURS Slovak, with English replay so English is not
  forgotten;
- voice locking (v4.0): 1,800-2,500 sentences synthesised per voice, only the takes that the Slovak Whisper
  transcribed without an error kept, and the model fine-tuned on them;
- `sk_a`: that model fine-tuned on its speaker's 3 hours of Common Voice recordings (best at 3,000 steps), with
  BigVGAN fine-tuned on the model's own mels of the voice (4,000 steps).

Everything was trained on one RTX 3080.

## All versions

| Version | What changed | Download |
|---|---|---|
| v1.0 | English base model: 590 voices, two speaking styles, fast mode, voice cloning (internal name v2.3) | `hf download mmmhusto/Regulus --revision v1.0` |
| v2.0 | Fine-tune of v1.0 on two voices: Studio 92 (Cori Samuel) and DailyTalk man | `hf download mmmhusto/Regulus --revision v2.0` |
| **v2.1** | **English: v2.0 with a fast mode (2-step decoder + Vocos, ~9x real time on a laptop CPU), voice cloning and a measured recipe for adding a voice (5 min of speech)** | `hf download mmmhusto/Regulus --revision v2.1` |
| v3.0 | First bilingual try: v2.0 plus experimental Slovak (5 voices) | `hf download mmmhusto/Regulus --revision v3.0` |
| v4.0 | Slovak: three original synthetic voices (sk_f3, sk_f2, sk_m1), about 1 % character error rate | `hf download mmmhusto/Regulus --revision v4.0` |
| v5.0 | Slovak: voice `sk_a`, a real speaker's natural reading voice; foreign names read the way Slovaks say them, ten / jeden / mladé read hard, clearer ť ď ň | `hf download mmmhusto/Regulus --revision v5.0` |
| **v5.1** | **v5.0 with times read the way people say them: o 14:30 -> o štrnásť tridsať (a whole hour stays o pätnástej), medzi 10:00 a 11:00 -> medzi desiatou a jedenástou** | `hf download mmmhusto/Regulus --revision v5.1` |

The repository was called TTS-husto (and TTS-English) before; the old names redirect here.

## Data and attribution

- [TrePal](https://huggingface.co/datasets/streams-sro/trepal), CC BY 4.0, © Národná rada Slovenskej republiky
  (nrsr.sk, tv.nrsr.sk), segmentation and alignment by Streams s.r.o.
- [Lili](https://huggingface.co/datasets/vsisik/voice-dataset-lili), Open Home Foundation, CC0.
- [FLEURS](https://huggingface.co/datasets/google/fleurs) Slovak, Google, CC BY 4.0.
- sk_a: [Mozilla Common Voice](https://commonvoice.mozilla.org) 22 Slovak (CC0), restored with Sidon
  ([sarulab-speech/commonvoice22_sidon](https://huggingface.co/datasets/sarulab-speech/commonvoice22_sidon)).
- English base model data (HiFi-TTS, DailyTalk and others) and BigVGAN: see
  [v1.0](https://huggingface.co/mmmhusto/Regulus/tree/v1.0) and [v2.0](https://huggingface.co/mmmhusto/Regulus/tree/v2.0).