File size: 15,973 Bytes
bdace62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41fb90a
bdace62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41fb90a
bdace62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41fb90a
 
 
bdace62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41fb90a
bdace62
 
 
 
 
 
 
 
 
41fb90a
bdace62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41fb90a
 
 
 
 
 
 
 
 
 
bdace62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41fb90a
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
---
license: cc0-1.0
language:
  - de
pipeline_tag: text-to-speech
library_name: piper
tags:
  - text-to-speech
  - tts
  - piper
  - vits
  - german
  - cc0
  - base-model
datasets:
  - Thorsten-Voice/TV-44kHz-Full
base_model: Thorsten-Voice/Piper-Scratch
---

# Thorsten-Voice Piper Base (German, male, CC0)

A German male **Piper base model trained exclusively on my Thorsten-Voice CC0 data**, with no lessac checkpoint or any other third-party model anywhere in its history.

**This model is primarily meant as a starting point for fine-tuning.** If you want to train your own Piper voice and need to be sure that no restrictively licensed data is hidden somewhere in the model's ancestry, this is what it was made for. You *can* use it directly as a voice (see [Using the model directly](#using-the-model-directly-with-piper)), but the main part of this documentation explains how to fine-tune your own Piper voice on top of it.

> **Why does this exist?** Most Piper voices are fine-tuned from the `lessac` checkpoint, whose dataset license is unclear for commercial use. This base model offers a fully CC0 alternative for German male voices.

---

## Contents

- [Provenance](#provenance)
- [Files in this repository](#files-in-this-repository)
- [Audio samples](#audio-samples)
- [Fine-tuning guide](#fine-tuning-guide) ← main part
- [Using the model directly with Piper](#using-the-model-directly-with-piper)
- [Training details](#training-details)
- [Training curves](#training-curves)
- [Limitations](#limitations)
- [License](#license)

---

## Provenance

Every step of this chain uses only Thorsten Müller's own recordings, released as CC0:

```
1. Piper-Scratch   trained from scratch (random init, no lessac, no warmstart)
                   on Thorsten-Voice 2022.10-Neutral, ~10 h, 1800 epochs
                   → https://huggingface.co/Thorsten-Voice/Piper-Scratch
        │
        ▼  warmstart (weights only, epoch 1799)
2. This base       trained on Thorsten-Voice 2021.02-Neutral + 2022.10-Neutral,
                   ~32.4 h, 1000 epochs
```

All training data: [Thorsten-Voice/TV-44kHz-Full](https://huggingface.co/datasets/Thorsten-Voice/TV-44kHz-Full) (CC0).

---

## Files in this repository

| Path | Purpose |
|---|---|
| `checkpoints/epoch=961-val_mel=0.3871.ckpt` | **Recommended base for fine-tuning.** Best validation mel loss of the whole run. |
| `checkpoints/epoch=751-val_mel=0.3883.ckpt` | Alternative base from an earlier stage of the run. Equivalent in blind listening tests. |
| `config.json` | Piper config (phoneme map, audio settings), required for training and inference |
| `onnx/` | Exported ONNX models + `.onnx.json` for direct use with Piper |
| `samples/` | Audio samples (identical texts for every model) |
| `runs/` | TensorBoard event file and `hparams.yaml` of the full training run |
| `data/stats.csv` | Per-utterance statistics (subset, style, microphone, duration) of the training data |
| `prep_tv44k_piper.py` | The data preparation script used for this model |

The `.ckpt` files (≈ 800 MB each) contain generator **and** discriminator weights. Use them for fine-tuning: starting with a trained discriminator makes fine-tuning considerably more stable. The ONNX files are for inference only and cannot be used for training.

---

## Audio samples

All samples use the same texts. `samples/absatz.txt` contains the long paragraph; `testsaetze/` contains 20 short test sentences.

| Model | Paragraph |
|---|---|
| Piper-Scratch (epoch 1799, ~10 h) | <audio controls src="https://huggingface.co/Thorsten-Voice/Piper-Base/resolve/main/samples/scratch_e1799/absatz.wav"></audio> |
| **Base, epoch 961** (recommended) | <audio controls src="https://huggingface.co/Thorsten-Voice/Piper-Base/resolve/main/samples/base_e961/absatz.wav"></audio> |
| Base, epoch 751 | <audio controls src="https://huggingface.co/Thorsten-Voice/Piper-Base/resolve/main/samples/base_e751/absatz.wav"></audio> |

---

## Fine-tuning guide

This guide shows how to fine-tune your own Piper voice on top of this base model. The example uses the CC0 dataset *Thorsten-Voice 2022.10-Neutral*. The same steps apply to your own recordings.

### 0. A note on licensing

The base model is CC0. **The license of your fine-tuned voice depends on the data you fine-tune with.** If you use only CC0 data (or your own recordings that you release as CC0), the whole chain stays CC0. If you use data under other licenses, those terms apply to your result.

### 1. Requirements

- Linux with an NVIDIA GPU. 24 GB VRAM is comfortable; this base was trained on a 48 GB A40 with batch size 32 using ~39 GB. Reduce `batch_size` on smaller cards.
- [piper1-gpl](https://github.com/OHF-Voice/piper1-gpl), installed for training as described in its training documentation.
  This model was trained with commit `COMMIT_HASH` (COMMIT_DATE). piper1-gpl is under active development, so if something in this guide no longer works, check out this commit:
  `git clone https://github.com/OHF-Voice/piper1-gpl && cd piper1-gpl && git checkout COMMIT_HASH`
  The only local change was `dynamo=False` in the ONNX export (see [step 7](#7-export-to-onnx)).
- `espeak-ng`.
- Additional Python packages that are not always pulled in by `[train]`:
  - `torchaudio`: needed for the UTMOS-based `val_mos` metric. Without it, training can crash after the first epoch.
  - `onnxscript`: needed for ONNX export.
- Disk space: the training cache needs roughly **1 GB per hour of audio** (audio and spectrograms are cached as tensors), plus about 9 GB for checkpoints. Lightning keeps the 5 best checkpoints per metric plus `last.ckpt`, each ≈ 800 MB.

### 2. Prepare your data

piper1-gpl expects:

- a folder with WAV files: **22,050 Hz, mono, 16-bit PCM**
- a `metadata.csv` with one line per file, in the form `filename.wav|Text of the utterance`

Recommendations for good results:

- **One speaker**, consistent recording setup, little background noise.
- Trim leading and trailing silence and leave a short pad (~0.15 s).
- Normalize loudness across all files (for example to −23 LUFS). Mixed loudness gets learned as unwanted variation.
- Remove clips with clipping, cut-off endings, or text that doesn't match the audio.
- Keep utterances roughly between 1 and 15 seconds.
- More data helps, but even a few hours of clean recordings work well on top of a base model.

**Example: Thorsten-Voice 2022.10 (CC0).** The script in this repository downloads the dataset from Hugging Face, filters it, resamples it to 22,050 Hz and writes `metadata.csv`:

```bash
pip install datasets soundfile soxr librosa pyloudnorm
python prep_tv44k_piper.py --out ./tv_2022 --subsets TV-2022.10-Neutral
```

It prints how many hours were written and how many clips were discarded for which reason, and writes per-clip statistics to `stats.csv`. For your own recordings, adapt the loading part or apply the same steps with tools of your choice.

### 3. Download the base checkpoint

```bash
hf download Thorsten-Voice/Piper-Base \
  "checkpoints/epoch=961-val_mel=0.3871.ckpt" config.json \
  --local-dir ./base
```

(Older installations use `huggingface-cli download` with the same arguments.)

### 4. Start the fine-tuning

```bash
python3 -m piper.train fit \
  --data.voice_name "de_DE-myvoice-medium" \
  --data.csv_path ./tv_2022/metadata.csv \
  --data.audio_dir ./tv_2022/wavs \
  --data.espeak_voice "de" \
  --data.cache_dir ./tv_2022/cache \
  --data.config_path ./tv_2022/config.json \
  --data.batch_size 32 \
  --data.num_workers 8 \
  --data.validation_split 0.02 \
  --model.sample_rate 22050 \
  --model.warmstart_ckpt "./base/checkpoints/epoch=961-val_mel=0.3871.ckpt" \
  --trainer.default_root_dir ./runs \
  --trainer.max_epochs 300
```

What the important options do:

| Option | Notes |
|---|---|
| `--model.warmstart_ckpt` | Loads the base model's **weights only**. Optimizer, learning-rate schedule and epoch counter start fresh, which is what you want for fine-tuning. The log should report all parameters as copied and none skipped. |
| `--trainer.max_epochs` | **Also controls the learning-rate schedule**: the learning rate is annealed to 5 % of its initial value over exactly this many epochs. Set it to what you actually intend to run. Stopping early leaves the learning rate high. |
| `--data.num_workers` | The default is 1, which starves the GPU. 8–12 workers took GPU utilization from ~40 % to ~75–100 % in this project. |
| `--data.batch_size` | 32 used ~39 GB VRAM. Reduce if you run out of memory; avoid changing the utterance length limits instead. |
| `--data.espeak_voice` | `de` for German. The base model has only seen German phonemes (see [Limitations](#limitations)). |
| `--data.config_path` | Written by the training run. Copy this file next to your exported ONNX model later. |

How many epochs? There is no single right answer. It depends on how much data you have and how far your voice is from Thorsten's. A practical approach is to set a moderate `max_epochs`, listen to intermediate checkpoints, and resume with `--ckpt_path <run>/checkpoints/last.ckpt` if you want to continue. A resumed run continues the learning-rate schedule seamlessly.

Run the training inside `tmux` or `screen` so it survives a closed SSH session.

> **Expected warning:** piper1-gpl may warn about low "vocoder coverage" (fewer than ~150 passes over the training waveform). With a warmstarted decoder this is much less of a concern than when training from scratch. Judge by listening.

### 5. Monitor the training

```bash
tensorboard --logdir ./runs/lightning_logs --port 6006
# on your local machine:
ssh -L 6006:localhost:6006 user@server   → open http://localhost:6006
```

The metrics worth watching:

- **`val_mel`**: the main metric, and the one checkpoints are named after. It should fall steadily and flatten out over time.
- **`val_mos`**: automatic quality estimate (UTMOS). It is noisy, so look at the trend and don't pick checkpoints by it alone.
- **`val_kl`, `val_fm`**: slowly rising values are common with VITS and were harmless in this run, as long as `val_mel` and the actual sound keep improving.

New `epoch=…-val_mel=…ckpt` files keep appearing as long as the model is still improving.

### 6. Listen and choose a checkpoint

Metrics only tell half the story. Synthesize the same set of sentences with several checkpoints and compare them, ideally **blind** (randomized A/B order, key opened only afterwards). In this project, differences that looked meaningful in the curves were often inaudible, and vice versa.

### 7. Export to ONNX

```bash
python3 -m piper.train.export_onnx \
  --checkpoint "./runs/lightning_logs/version_0/checkpoints/epoch=XXX-val_mel=X.XXXX.ckpt" \
  --output-file de_DE-myvoice-medium.onnx
cp ./tv_2022/config.json de_DE-myvoice-medium.onnx.json
```

> **Known issue with recent PyTorch versions:** the new dynamo-based ONNX exporter fails on VITS' spline flows (a data-dependent assert in `transforms.py`). Passing `dynamo=False` to `torch.onnx.export` in piper1-gpl's `export_onnx.py` fixes it. The export also requires `onnxscript`. Tracer warnings during export are normal.

### 8. Test your voice

```bash
echo "Hallo, das ist meine eigene Piper-Stimme." | \
  python3 -m piper -m de_DE-myvoice-medium.onnx -f test.wav
```

Piper looks for the config automatically as `<model>.onnx.json` next to the `.onnx` file.

---

## Using the model directly with Piper

The base model is a complete, working voice and can be used as-is, even though it was not primarily designed for that. Download an ONNX model together with its `.onnx.json` and use it like any other Piper voice:

```bash
hf download Thorsten-Voice/Piper-Base \
  onnx/base_e961.onnx onnx/base_e961.onnx.json --local-dir .

echo "Guten Morgen! Wie geht es dir heute?" | \
  python3 -m piper -m onnx/base_e961.onnx --length-scale 0.85 -f output.wav
```

**Recommendation: `length_scale` ≈ 0.82–0.85.** About 70 % of the training data comes from the 2021 recordings, which were spoken slowly and very carefully. The base model inherits that tempo. To make this the default for every application, including Home Assistant, set it in the `.onnx.json`:

```json
"inference": {
  "noise_scale": 0.667,
  "length_scale": 0.85,
  "noise_w": 0.8
}
```

For the best quality of my own voice, use the dedicated Thorsten-Voice Piper models, or fine-tune this base on the 2022.10 dataset as shown above.

---

## Training details

### Data

| Subset | Hours | Notes |
|---|---|---|
| TV-2021.02-Neutral | 22.7 h | slow, very clear articulation; partly recorded with a "bad" USB headset |
| TV-2022.10-Neutral | 9.7 h | studio microphone (Rode Podcaster), more natural tempo |
| **Total** | **32.4 h** | 34,345 utterances, single speaker |

Not used: *2021.06-Emotional* (extreme styles such as whispering, drunk and sleepy were excluded; all remaining clips were flagged as possibly cut off at the end) and *2023.09-Hessisch* (dialect).

Preprocessing (`prep_tv44k_piper.py`): silence trimming with 0.15 s padding, loudness normalization to −23 LUFS, peak limiting to −1 dBFS, resampling 44.1 kHz → 22.05 kHz (soxr VHQ). Discarded clips: those with comments in the dataset, durations outside 0.8–15 s, implausible characters per second (outside 6–25, a hint at text/audio mismatches) or clipping.

### Training

| Setting | Value |
|---|---|
| Framework | piper1-gpl (VITS), quality `medium` |
| Sample rate | 22,050 Hz |
| Initialization | warmstart from Piper-Scratch, epoch 1799 (784/784 parameters copied) |
| Epochs | 1000 (1051 steps per epoch) |
| Batch size | 32 |
| Validation split | 2 % |
| Learning rate | annealed to 5 % of the initial value over 1000 epochs |
| Hardware | 1 × NVIDIA A40 (48 GB), ~12–15 min per epoch, ~10 days total |

The full TensorBoard log is included in `runs/`.

### Results

| Checkpoint | `val_mel` | Notes |
|---|---|---|
| epoch 1 | 0.4579 | start of the run |
| epoch 751 | 0.3883 | best value of the middle phase |
| **epoch 961** | **0.3871** | **best value of the entire run** |
| epoch 999 | ~0.388 | final state |

Best `val_mos` (UTMOS estimate): 3.67 at epoch 892.

Blind A/B listening tests with 20 sentences each:

- epoch 615 vs. 751: **10 : 10**. No audible difference.
- epoch 961 vs. 999: **12 : 8** in favour of 961. Slight tendency, not statistically significant.

Compared with Piper-Scratch (10 h only), the base model pronounces and stresses less common words clearly more naturally. That was the purpose of the additional data.

---

## Training curves

The complete TensorBoard log is in `runs/` (also available in the *Training metrics* tab). The most important curves at a glance:

| Validation mel loss (`val_mel`) | Quality estimate (`val_mos`, UTMOS) |
|---|---|
| ![val_mel](plots/val_mel.png) | ![val_mos](plots/val_mos.png) |

---

## Limitations

- **German only.** The base has only seen German phonemes from espeak-ng. Fine-tuning for other languages may work for shared sounds but has not been tested.
- **Slower speaking tempo** inherited from the 2021 recordings (see above). Fine-tuning adopts the tempo of the target voice.
- **Recording quality:** most of the data was recorded with a headset, so the base sounds somewhat duller than studio recordings. Fine-tuning on clean data recovers clarity.
- **Phonemization errors** come from espeak-ng, not from the model. Example: "Intendantin" is stressed incorrectly. These can be fixed with custom espeak-ng dictionary entries, without retraining.
- **Quality level `medium` only.**

---

## License

**CC0 1.0 Universal.** Model, checkpoints, configuration, samples and scripts are dedicated to the public domain. No attribution is required, but it is always appreciated.

## Credits

- Voice, recordings, datasets and training: **Thorsten Müller** / [Thorsten-Voice](https://www.thorsten-voice.de)
- [Piper](https://github.com/OHF-Voice/piper1-gpl) by Michael Hansen and the Open Home Foundation