Chatterbox-TTS (sk)
Browse files- .gitattributes +4 -0
- sk/chatterbox-tts-slovak/.gitattributes +39 -0
- sk/chatterbox-tts-slovak/GUIDE.md +528 -0
- sk/chatterbox-tts-slovak/README.md +179 -0
- sk/chatterbox-tts-slovak/samples/01_greeting.wav +3 -0
- sk/chatterbox-tts-slovak/samples/02_narrative.wav +3 -0
- sk/chatterbox-tts-slovak/samples/03_explanation.wav +3 -0
- sk/chatterbox-tts-slovak/samples/04_long_narrative.wav +3 -0
- sk/chatterbox-tts-slovak/source.txt +1 -0
- sk/chatterbox-tts-slovak/t3_sk_v2.2.safetensors +3 -0
.gitattributes
CHANGED
|
@@ -99,3 +99,7 @@ en/chatterbox-turbo-webgpu/onnx/embed_tokens_q4f16.onnx_data filter=lfs diff=lfs
|
|
| 99 |
en/chatterbox-turbo-webgpu/onnx/language_model_q4f16.onnx_data filter=lfs diff=lfs merge=lfs -text
|
| 100 |
en/chatterbox-turbo-webgpu/onnx/speech_encoder_q4f16.onnx_data filter=lfs diff=lfs merge=lfs -text
|
| 101 |
multi/chatterbox-multilingual-ONNX-q4/default_voice.wav filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
en/chatterbox-turbo-webgpu/onnx/language_model_q4f16.onnx_data filter=lfs diff=lfs merge=lfs -text
|
| 100 |
en/chatterbox-turbo-webgpu/onnx/speech_encoder_q4f16.onnx_data filter=lfs diff=lfs merge=lfs -text
|
| 101 |
multi/chatterbox-multilingual-ONNX-q4/default_voice.wav filter=lfs diff=lfs merge=lfs -text
|
| 102 |
+
sk/chatterbox-tts-slovak/samples/01_greeting.wav filter=lfs diff=lfs merge=lfs -text
|
| 103 |
+
sk/chatterbox-tts-slovak/samples/02_narrative.wav filter=lfs diff=lfs merge=lfs -text
|
| 104 |
+
sk/chatterbox-tts-slovak/samples/03_explanation.wav filter=lfs diff=lfs merge=lfs -text
|
| 105 |
+
sk/chatterbox-tts-slovak/samples/04_long_narrative.wav filter=lfs diff=lfs merge=lfs -text
|
sk/chatterbox-tts-slovak/.gitattributes
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
samples/01_greeting.wav filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
samples/02_narrative.wav filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
samples/03_explanation.wav filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
samples/04_long_narrative.wav filter=lfs diff=lfs merge=lfs -text
|
sk/chatterbox-tts-slovak/GUIDE.md
ADDED
|
@@ -0,0 +1,528 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Fine-tuning Chatterbox on a Low-Resource Language: 7 Things That Mattered
|
| 2 |
+
|
| 3 |
+
> 🇸🇰 **Slovenská verzia nižšie** — [skoč na slovenský preklad](#fine-tuning-chatterboxu-na-málo-zastúpenom-jazyku-7-vecí-na-ktorých-záležalo).
|
| 4 |
+
|
| 5 |
+
Resemble AI's [Chatterbox Multilingual TTS](https://huggingface.co/ResembleAI/chatterbox) is one of the few SOTA open-source TTS models with a real MIT license — code *and* weights — so it's a natural starting point if you want to build a commercially usable text-to-speech for a language that the official model doesn't ship.
|
| 6 |
+
|
| 7 |
+
I fine-tuned it on Slovak. The 23 supported languages in the official multilingual checkpoint don't include it, and there was nothing comparable in the open-source ecosystem — every other halfway decent multilingual TTS I could find (XTTS-v2, F5-TTS, Fish Speech) ships under non-commercial licenses. So I trained my own and [published the weights](https://huggingface.co/pekiskol/chatterbox-tts-slovak).
|
| 8 |
+
|
| 9 |
+
The TTS sits at the end of a larger pipeline I'm building — an end-to-end Slovak video-dubbing tool (Whisper for transcription, a fine-tuned Gemma 3 for translation, MuseTalk for lip-sync) — and Slovak TTS was the missing piece. That's the reason "good enough on a single sentence" wasn't good enough; I needed audio that holds up across hours of generated speech.
|
| 10 |
+
|
| 11 |
+
The fine-tuning itself isn't the hard part. The hard part is the dozen tiny things that turn a "weights file that loads" into "weights file that produces audio you'd actually ship." Here are the seven that mattered most for me.
|
| 12 |
+
|
| 13 |
+
This post assumes you already know what fine-tuning a TTS is and have a base Chatterbox setup running. It's the practical-tuning notes I wish someone had written before I started.
|
| 14 |
+
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
## 1. The base model and your fine-tune disagree on vocab size
|
| 18 |
+
|
| 19 |
+
Chatterbox uses a sentencepiece text tokenizer, and depending on training data your fine-tune may end up with a different vocab size than the base multilingual checkpoint. If you naively `load_state_dict(strict=True)` the T3 weights into the base model, you get a shape mismatch.
|
| 20 |
+
|
| 21 |
+
The fix is to pad or trim the affected matrices (`text_emb.weight` and `text_head.weight`) before loading:
|
| 22 |
+
|
| 23 |
+
```python
|
| 24 |
+
state = load_safetensors(my_finetune_path, device="cpu")
|
| 25 |
+
|
| 26 |
+
target_vocab = model.t3.text_emb.weight.shape[0]
|
| 27 |
+
src_vocab = state["text_emb.weight"].shape[0]
|
| 28 |
+
|
| 29 |
+
if src_vocab > target_vocab:
|
| 30 |
+
state["text_emb.weight"] = state["text_emb.weight"][:target_vocab, :]
|
| 31 |
+
state["text_head.weight"] = state["text_head.weight"][:target_vocab, :]
|
| 32 |
+
elif src_vocab < target_vocab:
|
| 33 |
+
pad = target_vocab - src_vocab
|
| 34 |
+
emb_pad = state["text_emb.weight"].mean(dim=0, keepdim=True).repeat(pad, 1)
|
| 35 |
+
head_pad = state["text_head.weight"].mean(dim=0, keepdim=True).repeat(pad, 1)
|
| 36 |
+
state["text_emb.weight"] = torch.cat([state["text_emb.weight"], emb_pad], dim=0)
|
| 37 |
+
state["text_head.weight"] = torch.cat([state["text_head.weight"], head_pad], dim=0)
|
| 38 |
+
|
| 39 |
+
model.t3.load_state_dict(state, strict=True)
|
| 40 |
+
```
|
| 41 |
+
|
| 42 |
+
Padding with the row mean instead of zeros gives you a sensible "neutral" embedding for tokens the fine-tune never saw — better than zeros, which produce noise.
|
| 43 |
+
|
| 44 |
+
---
|
| 45 |
+
|
| 46 |
+
## 2. The reference audio matters more than you think
|
| 47 |
+
|
| 48 |
+
Chatterbox is a zero-shot voice-cloning model. You give it a few seconds of someone speaking, and the output mimics that voice. Most articles stop there. They don't tell you that **whatever noise is in your reference clip will be baked into every generation**.
|
| 49 |
+
|
| 50 |
+
I was using a 5.7-second Common Voice Slovak clip as the reference. The model output was almost perfect — but had a faint low-frequency hum throughout. Same hum that was in the reference, which I hadn't noticed until I heard it stretched across thirty seconds of generated audio.
|
| 51 |
+
|
| 52 |
+
The fix is to clean the reference *before* you pass it to the model. Here's the ffmpeg chain I ended up with:
|
| 53 |
+
|
| 54 |
+
```bash
|
| 55 |
+
ffmpeg -i reference.wav -af "
|
| 56 |
+
highpass=f=70,
|
| 57 |
+
afftdn=nr=12:nt=w:om=o,
|
| 58 |
+
lowpass=f=11000,
|
| 59 |
+
equalizer=f=6800:t=q:w=1.2:g=-1.5,
|
| 60 |
+
silenceremove=start_periods=1:start_silence=0.04:start_threshold=-50dB,
|
| 61 |
+
areverse,
|
| 62 |
+
silenceremove=start_periods=1:start_silence=0.06:start_threshold=-46dB,
|
| 63 |
+
areverse
|
| 64 |
+
" reference_clean.wav
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
What each stage does:
|
| 68 |
+
|
| 69 |
+
- `highpass=70` removes mains hum and low-frequency rumble
|
| 70 |
+
- `afftdn` is FFT-based broadband denoising (12 dB reduction is gentle — pushing it higher starts to make speech metallic)
|
| 71 |
+
- `lowpass=11000` cuts hiss above 11 kHz, which Chatterbox doesn't reproduce anyway
|
| 72 |
+
- The `equalizer` notch around 6.8 kHz tames sibilance
|
| 73 |
+
- The pair of `silenceremove` + `areverse` blocks trims silence from both ends without complicated edge-case handling
|
| 74 |
+
|
| 75 |
+
This matters because cloning is essentially a "voice colour transfer" — anything in the reference *is* part of the cloned voice. Garbage in, garbage out.
|
| 76 |
+
|
| 77 |
+
---
|
| 78 |
+
|
| 79 |
+
## 3. Generation parameters: defaults vs. tuned
|
| 80 |
+
|
| 81 |
+
The default `model.generate()` call works, but you can do better. After regression-testing on Slovak segments, I landed on these:
|
| 82 |
+
|
| 83 |
+
| Param | Default | Tuned for stability | Notes |
|
| 84 |
+
|----------------------|---------|---------------------|------------------------------------------|
|
| 85 |
+
| `exaggeration` | 0.5 | 0.5 | Same |
|
| 86 |
+
| `cfg_weight` | 0.5 | 0.5 | Same |
|
| 87 |
+
| `temperature` | 0.8 | 0.6 | Lower → more stable, less variable |
|
| 88 |
+
| `top_p` | 1.0 | 0.92 | Cuts the long tail of low-prob samples |
|
| 89 |
+
| `repetition_penalty` | 1.0 | 1.25 | Prevents the model getting stuck on syllables |
|
| 90 |
+
|
| 91 |
+
There's a real **trade-off** here: tuned parameters produce more consistent, less-likely-to-fail output, but they also flatten the prosody. The voice sounds slightly more monotone. For a production pipeline doing thousands of segments per day where any failure is worse than a slightly less expressive read, tuned wins. For a demo on a model card where you want one perfect take, default temperature with a deterministic seed and a retry loop wins.
|
| 92 |
+
|
| 93 |
+
```python
|
| 94 |
+
RETRY_SEEDS = [42, 0, 123, 7, 99]
|
| 95 |
+
min_dur = max(0.3, len(text) / 25.0)
|
| 96 |
+
|
| 97 |
+
for seed in RETRY_SEEDS:
|
| 98 |
+
torch.manual_seed(seed)
|
| 99 |
+
wav = model.generate(text=text, language_id="sk")
|
| 100 |
+
if wav.shape[-1] / model.sr >= min_dur:
|
| 101 |
+
break
|
| 102 |
+
```
|
| 103 |
+
|
| 104 |
+
The retry loop catches the cases where the model produces a too-short output (it sometimes EOSes early on hard inputs). If the first seed works, you stop; if not, try another. Five seeds is plenty in practice.
|
| 105 |
+
|
| 106 |
+
---
|
| 107 |
+
|
| 108 |
+
## 4. The first word can be garbage. Add a warmup prefix.
|
| 109 |
+
|
| 110 |
+
Generating "Slovenský jazyk je úradný..." would sometimes produce "Zvolenský jazyk..." — the model's first token after the reference would morph. Sometimes the entire first word would be quiet noise.
|
| 111 |
+
|
| 112 |
+
This is a "warmup" artifact: the model has to transition from the reference voice's prosody to its own generation, and that first ~0.3 s is where it can wobble. Hard words at position zero hit hardest.
|
| 113 |
+
|
| 114 |
+
Two fixes, both work:
|
| 115 |
+
|
| 116 |
+
**Reword.** If "Slovenský" trips the model, start with "Slovenčina" instead. Easy, free, doesn't always work.
|
| 117 |
+
|
| 118 |
+
**Add a warmup prefix.** Put a short, easy phrase at the start that the model can land on cleanly:
|
| 119 |
+
|
| 120 |
+
```
|
| 121 |
+
Vitajte v ukážke.
|
| 122 |
+
Slovenčina je úradný jazyk Slovenskej republiky.
|
| 123 |
+
...
|
| 124 |
+
```
|
| 125 |
+
|
| 126 |
+
By the time the model reaches "Slovenčina," it has stabilised. The prefix becomes part of the generation but is short and natural, and you can always trim it in post if you don't want it.
|
| 127 |
+
|
| 128 |
+
This isn't unique to Chatterbox — most autoregressive TTS models have warmup behaviour at the very start. The fix transfers.
|
| 129 |
+
|
| 130 |
+
---
|
| 131 |
+
|
| 132 |
+
## 5. The model can't read out individual letter names
|
| 133 |
+
|
| 134 |
+
I tried generating "Má bohatú gramatiku, sedem pádov a špecifické hlásky ako ô, ľ alebo ŕ." — a sentence that names individual Slovak letters. The model produced nonsense for the letter-name part.
|
| 135 |
+
|
| 136 |
+
This is a known limitation of TTS models trained on running speech: they rarely see "the letter ô" as a phrase, so they don't know it should be pronounced as a name rather than as the sound itself. The same is true of acronyms ("NDA" gets read as "enda") and units ("20 %" sometimes becomes "two-hundred percent" because of how digit-percent pairs were tokenised in training data).
|
| 137 |
+
|
| 138 |
+
The fix is text normalisation *before* TTS. In my pipeline I have a small Slovak-specific preprocessor that rewrites:
|
| 139 |
+
|
| 140 |
+
- `20 %` → `dvadsať percent`
|
| 141 |
+
- `Y100` → `ypsilon sto`
|
| 142 |
+
- `NDA` → `eN-Dý-Á`
|
| 143 |
+
- Letter names → spelled-out phonetic forms
|
| 144 |
+
|
| 145 |
+
This lives as a preprocessing layer, not part of the model. It's easier to fix text once than to retrain the model to handle every edge case.
|
| 146 |
+
|
| 147 |
+
---
|
| 148 |
+
|
| 149 |
+
## 6. `max_new_tokens` matters for long generations
|
| 150 |
+
|
| 151 |
+
Chatterbox auto-scales the generation budget:
|
| 152 |
+
|
| 153 |
+
```python
|
| 154 |
+
_max_toks = max_new_tokens or min(4096, max(1000, len(text) * 8))
|
| 155 |
+
```
|
| 156 |
+
|
| 157 |
+
For a 350-character text that gives 2800 tokens, which sounds like plenty (at ~25 Hz token rate that's over 100 seconds of audio). But the model can EOS early on a particular word — even with a budget far above what the text needs. I had a 30-second narrative whose final word ("Amerike") got cut short despite a 4096-token budget.
|
| 158 |
+
|
| 159 |
+
When you have a long input, **set `max_new_tokens=4096` explicitly** and check for premature EOS in postprocessing. If your output ends mid-word, treat it as a generation failure and retry with a different seed (see #3).
|
| 160 |
+
|
| 161 |
+
For very long inputs, a more reliable strategy is to chunk into sentences, generate each separately, and concatenate with a short crossfade. Chatterbox doesn't have first-class chunking yet, so you do this at the application layer.
|
| 162 |
+
|
| 163 |
+
---
|
| 164 |
+
|
| 165 |
+
## 7. Use `prepare_conditionals` separately from `generate`
|
| 166 |
+
|
| 167 |
+
The Chatterbox API supports passing `audio_prompt_path=` directly to `generate()`, but in a production loop where you're generating many segments with the same voice, it's faster to call `prepare_conditionals` once and reuse:
|
| 168 |
+
|
| 169 |
+
```python
|
| 170 |
+
model.prepare_conditionals(reference_path)
|
| 171 |
+
|
| 172 |
+
# Now generate many times without re-loading reference each time
|
| 173 |
+
for text in texts:
|
| 174 |
+
wav = model.generate(text=text, language_id="sk")
|
| 175 |
+
```
|
| 176 |
+
|
| 177 |
+
The conditioning extracts speaker-identity features from the reference. Doing it once amortises the cost across the loop. For one-off demos it doesn't matter; for batch jobs it can shave noticeable time.
|
| 178 |
+
|
| 179 |
+
A related gotcha: if you switch reference voices mid-loop, remember to re-run `prepare_conditionals` (or null `model.conds`) before the next generation, or you'll keep cloning the previous voice.
|
| 180 |
+
|
| 181 |
+
---
|
| 182 |
+
|
| 183 |
+
## Final recipe
|
| 184 |
+
|
| 185 |
+
Putting it together — the inference snippet I'd hand to someone starting fresh:
|
| 186 |
+
|
| 187 |
+
```python
|
| 188 |
+
import torch, torchaudio, subprocess
|
| 189 |
+
from chatterbox.mtl_tts import ChatterboxMultilingualTTS
|
| 190 |
+
from safetensors.torch import load_file
|
| 191 |
+
|
| 192 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 193 |
+
|
| 194 |
+
# 1. Clean the reference
|
| 195 |
+
subprocess.run([
|
| 196 |
+
"ffmpeg", "-y", "-i", "reference.wav",
|
| 197 |
+
"-af",
|
| 198 |
+
"highpass=f=70,afftdn=nr=12,lowpass=f=11000,"
|
| 199 |
+
"equalizer=f=6800:t=q:w=1.2:g=-1.5,"
|
| 200 |
+
"silenceremove=start_periods=1:start_silence=0.04:start_threshold=-50dB,"
|
| 201 |
+
"areverse,silenceremove=start_periods=1:start_silence=0.06:start_threshold=-46dB,"
|
| 202 |
+
"areverse",
|
| 203 |
+
"reference_clean.wav",
|
| 204 |
+
], check=True)
|
| 205 |
+
|
| 206 |
+
# 2. Load base + patch in fine-tune
|
| 207 |
+
model = ChatterboxMultilingualTTS.from_pretrained(device=device)
|
| 208 |
+
state = load_file("my_finetune_t3.safetensors", device="cpu")
|
| 209 |
+
# vocab resize block from #1 here
|
| 210 |
+
model.t3.load_state_dict(state, strict=True)
|
| 211 |
+
model.t3.to(device).eval()
|
| 212 |
+
|
| 213 |
+
# 3. Prepare reference once
|
| 214 |
+
model.prepare_conditionals("reference_clean.wav")
|
| 215 |
+
|
| 216 |
+
# 4. Generate with retry
|
| 217 |
+
text = "Vitajte v ukážke. " + your_actual_text # warmup prefix from #4
|
| 218 |
+
RETRY_SEEDS = [42, 0, 123, 7, 99]
|
| 219 |
+
min_dur = max(0.3, len(text) / 25.0)
|
| 220 |
+
|
| 221 |
+
wav = None
|
| 222 |
+
for seed in RETRY_SEEDS:
|
| 223 |
+
torch.manual_seed(seed)
|
| 224 |
+
with torch.inference_mode():
|
| 225 |
+
candidate = model.generate(text=text, language_id="sk", max_new_tokens=4096)
|
| 226 |
+
if candidate.shape[-1] / model.sr >= min_dur:
|
| 227 |
+
wav = candidate
|
| 228 |
+
break
|
| 229 |
+
|
| 230 |
+
torchaudio.save("output.wav", wav.cpu(), model.sr)
|
| 231 |
+
```
|
| 232 |
+
|
| 233 |
+
This is roughly what's running in my pipeline today.
|
| 234 |
+
|
| 235 |
+
---
|
| 236 |
+
|
| 237 |
+
## What didn't work
|
| 238 |
+
|
| 239 |
+
A few things I tried that turned out to be dead ends, in case you're tempted by them:
|
| 240 |
+
|
| 241 |
+
- **Aggressive denoising** of the reference (FFT noise reduction at -18 dB or higher). Removes hum reliably but starts producing a metallic, "phasey" cloned voice. -12 dB is the sweet spot.
|
| 242 |
+
- **`temperature=0.4` or below**. Flattens prosody to the point of sounding like a robocall.
|
| 243 |
+
- **Skipping the warmup prefix and trimming the first 0.3 s in post**. Works *most* of the time, but occasionally cuts the start of an actually-clean first word. The prefix is more reliable.
|
| 244 |
+
- **Trying to fix the EOS-early problem with `repetition_penalty=1.5` or higher**. Did not help; the model's stop decision is upstream of repetition logic.
|
| 245 |
+
|
| 246 |
+
---
|
| 247 |
+
|
| 248 |
+
## Wrapping up
|
| 249 |
+
|
| 250 |
+
If you're fine-tuning Chatterbox on a language it doesn't ship, the biggest things you can do *outside* the training loop are:
|
| 251 |
+
|
| 252 |
+
1. Clean your reference audio
|
| 253 |
+
2. Tune your generation params (or accept the defaults' trade-offs)
|
| 254 |
+
3. Normalise your text *before* it reaches the model
|
| 255 |
+
4. Use a warmup prefix for the first word
|
| 256 |
+
5. Set `max_new_tokens` explicitly and have a retry path
|
| 257 |
+
|
| 258 |
+
The Slovak fine-tune lives at [huggingface.co/pekiskol/chatterbox-tts-slovak](https://huggingface.co/pekiskol/chatterbox-tts-slovak) under MIT — drop in the inference snippet above and it should work out of the box. Feedback (or different language fine-tunes that hit the same gotchas) welcome on the model's HF discussions tab.
|
| 259 |
+
|
| 260 |
+
If you've discovered other Chatterbox tuning tricks I missed, leave a comment — I'd like to extend this list.
|
| 261 |
+
|
| 262 |
+
---
|
| 263 |
+
---
|
| 264 |
+
|
| 265 |
+
# Fine-tuning Chatterboxu na málo zastúpenom jazyku: 7 vecí, na ktorých záležalo
|
| 266 |
+
|
| 267 |
+
> 🇬🇧 **English version above** — [jump to English version](#fine-tuning-chatterbox-on-a-low-resource-language-7-things-that-mattered).
|
| 268 |
+
|
| 269 |
+
[Chatterbox Multilingual TTS](https://huggingface.co/ResembleAI/chatterbox) od Resemble AI je jeden z mála SOTA open-source TTS modelov so skutočne MIT licenciou — kód *aj* weights — takže je prirodzeným základom, ak chceš postaviť komerčne použiteľný text-to-speech pre jazyk, ktorý oficiálny model nepodporuje.
|
| 270 |
+
|
| 271 |
+
Dotrénoval som ho na slovenčinu. V 23 podporovaných jazykoch oficiálneho multilingual checkpointu slovenčina nie je, a v open-source ekosystéme nebolo nič porovnateľné — všetky ostatné aspoň trochu slušné multilingual TTS modely (XTTS-v2, F5-TTS, Fish Speech) sú pod nekomerčnými licenciami. Tak som si vyrobil vlastný a [zverejnil weights](https://huggingface.co/pekiskol/chatterbox-tts-slovak).
|
| 272 |
+
|
| 273 |
+
TTS sedí na konci väčšej pipeline, ktorú staviam — end-to-end nástroj na dabovanie videí do slovenčiny (Whisper na rozpoznávanie reči, fine-tuned Gemma 3 na preklad, MuseTalk na synchronizáciu úst) — a slovenský TTS bol chýbajúci kúsok. To je dôvod, prečo "dosť dobré na jednu vetu" nestačilo; potreboval som audio, ktoré ustojí hodiny generovanej reči.
|
| 274 |
+
|
| 275 |
+
Samotný fine-tuning nie je ten ťažký problém. Ten ťažký je tucet drobností, ktoré spravia z "weights súbor ktorý sa načíta" niečo ako "weights súbor čo produkuje audio aké by si reálne dodal klientovi". Tu je sedem, ktoré pre mňa zavážili najviac.
|
| 276 |
+
|
| 277 |
+
Tento článok predpokladá že vieš čo je fine-tuning TTS modelu a máš sfunkčnené základné Chatterbox prostredie. Sú to praktické tuning poznámky, ktoré som si želal aby niekto napísal predtým, než som začal.
|
| 278 |
+
|
| 279 |
+
---
|
| 280 |
+
|
| 281 |
+
## 1. Base model a tvoj fine-tune sa nezhodnú na vocab size
|
| 282 |
+
|
| 283 |
+
Chatterbox používa sentencepiece text tokenizer a podľa tréningových dát môže tvoj fine-tune skončiť s iným vocab size ako base multilingual checkpoint. Ak naivne urobíš `load_state_dict(strict=True)` s T3 weights do base modelu, dostaneš shape mismatch.
|
| 284 |
+
|
| 285 |
+
Riešenie je padding alebo trim postihnutých matíc (`text_emb.weight` a `text_head.weight`) pred načítaním:
|
| 286 |
+
|
| 287 |
+
```python
|
| 288 |
+
state = load_safetensors(my_finetune_path, device="cpu")
|
| 289 |
+
|
| 290 |
+
target_vocab = model.t3.text_emb.weight.shape[0]
|
| 291 |
+
src_vocab = state["text_emb.weight"].shape[0]
|
| 292 |
+
|
| 293 |
+
if src_vocab > target_vocab:
|
| 294 |
+
state["text_emb.weight"] = state["text_emb.weight"][:target_vocab, :]
|
| 295 |
+
state["text_head.weight"] = state["text_head.weight"][:target_vocab, :]
|
| 296 |
+
elif src_vocab < target_vocab:
|
| 297 |
+
pad = target_vocab - src_vocab
|
| 298 |
+
emb_pad = state["text_emb.weight"].mean(dim=0, keepdim=True).repeat(pad, 1)
|
| 299 |
+
head_pad = state["text_head.weight"].mean(dim=0, keepdim=True).repeat(pad, 1)
|
| 300 |
+
state["text_emb.weight"] = torch.cat([state["text_emb.weight"], emb_pad], dim=0)
|
| 301 |
+
state["text_head.weight"] = torch.cat([state["text_head.weight"], head_pad], dim=0)
|
| 302 |
+
|
| 303 |
+
model.t3.load_state_dict(state, strict=True)
|
| 304 |
+
```
|
| 305 |
+
|
| 306 |
+
Padding cez priemer riadkov namiesto núl ti dá rozumné "neutrálne" embedding pre tokeny, ktoré fine-tune nikdy nevidel — lepšie ako nuly, ktoré produkujú šum.
|
| 307 |
+
|
| 308 |
+
---
|
| 309 |
+
|
| 310 |
+
## 2. Reference audio záleží viac, než si myslíš
|
| 311 |
+
|
| 312 |
+
Chatterbox je zero-shot voice cloning model. Dáš mu pár sekúnd niekoho hovoriaceho a výstup imituje ten hlas. Väčšina článkov sa tu zastaví. Nepovedia ti, že **akýkoľvek šum v reference klipe sa zapečie do každej generácie**.
|
| 313 |
+
|
| 314 |
+
Používal som 5,7-sekundový Common Voice slovenský klip ako reference. Výstup modelu bol skoro perfektný — ale s jemným nízkofrekvenčným hum cez celé. Ten istý hum bol v referenci, len som si ho nevšimol kým som ho nepočul roztiahnutý cez tridsať sekúnd generovaného audia.
|
| 315 |
+
|
| 316 |
+
Riešenie je vyčistiť reference *predtým*, než ho odovzdáš modelu. Tu je ffmpeg chain, na ktorý som došiel:
|
| 317 |
+
|
| 318 |
+
```bash
|
| 319 |
+
ffmpeg -i reference.wav -af "
|
| 320 |
+
highpass=f=70,
|
| 321 |
+
afftdn=nr=12:nt=w:om=o,
|
| 322 |
+
lowpass=f=11000,
|
| 323 |
+
equalizer=f=6800:t=q:w=1.2:g=-1.5,
|
| 324 |
+
silenceremove=start_periods=1:start_silence=0.04:start_threshold=-50dB,
|
| 325 |
+
areverse,
|
| 326 |
+
silenceremove=start_periods=1:start_silence=0.06:start_threshold=-46dB,
|
| 327 |
+
areverse
|
| 328 |
+
" reference_clean.wav
|
| 329 |
+
```
|
| 330 |
+
|
| 331 |
+
Čo robí každý stage:
|
| 332 |
+
|
| 333 |
+
- `highpass=70` odstráni mains hum a nízkofrekvenčný rumble
|
| 334 |
+
- `afftdn` je FFT-based broadband denoising (12 dB redukcia je jemná — vyššie hodnoty robia reč kovovou)
|
| 335 |
+
- `lowpass=11000` orezáva hiss nad 11 kHz, ktorý Chatterbox aj tak nereprodukuje
|
| 336 |
+
- `equalizer` notch okolo 6,8 kHz krotí sykavky
|
| 337 |
+
- Pár `silenceremove` + `areverse` orezáva ticho z oboch strán bez komplikovaného edge-case handling-u
|
| 338 |
+
|
| 339 |
+
Záleží na tom, lebo cloning je v podstate "voice colour transfer" — všetko v referenci *je* súčasťou klonovaného hlasu. Garbage in, garbage out.
|
| 340 |
+
|
| 341 |
+
---
|
| 342 |
+
|
| 343 |
+
## 3. Generation parametre: defaultné vs. tunované
|
| 344 |
+
|
| 345 |
+
Default `model.generate()` volanie funguje, ale dá sa to spraviť lepšie. Po regression-testoch na slovenských segmentoch som pristal na týchto:
|
| 346 |
+
|
| 347 |
+
| Param | Default | Tunované pre stabilitu | Poznámka |
|
| 348 |
+
|----------------------|---------|------------------------|------------------------------------------|
|
| 349 |
+
| `exaggeration` | 0.5 | 0.5 | To isté |
|
| 350 |
+
| `cfg_weight` | 0.5 | 0.5 | To isté |
|
| 351 |
+
| `temperature` | 0.8 | 0.6 | Nižšie → stabilnejšie, menej variability |
|
| 352 |
+
| `top_p` | 1.0 | 0.92 | Reže long tail nízkopravdepodobných samples |
|
| 353 |
+
| `repetition_penalty` | 1.0 | 1.25 | Zabráni modelu zaseknúť sa na slabikách |
|
| 354 |
+
|
| 355 |
+
Tu je reálny **trade-off**: tunované parametre dávajú konzistentnejší, menej náchylný-na-zlyhanie výstup, ale tiež plošia prozódiu. Hlas znie trochu monotónnejšie. Pre produkčnú pipeline robiacu tisíce segmentov denne, kde akékoľvek zlyhanie je horšie ako menej výrazný prejav, vyhráva tunovanie. Pre demo na model card, kde chceš jeden perfektný take, vyhráva default temperature s deterministickým seedom a retry loopom.
|
| 356 |
+
|
| 357 |
+
```python
|
| 358 |
+
RETRY_SEEDS = [42, 0, 123, 7, 99]
|
| 359 |
+
min_dur = max(0.3, len(text) / 25.0)
|
| 360 |
+
|
| 361 |
+
for seed in RETRY_SEEDS:
|
| 362 |
+
torch.manual_seed(seed)
|
| 363 |
+
wav = model.generate(text=text, language_id="sk")
|
| 364 |
+
if wav.shape[-1] / model.sr >= min_dur:
|
| 365 |
+
break
|
| 366 |
+
```
|
| 367 |
+
|
| 368 |
+
Retry loop chytí prípady, keď model vyprodukuje príliš krátky výstup (občas EOS-uje predčasne na ťažších vstupoch). Ak prvý seed vyšiel, končíš; ak nie, skús iný. Päť seedov stačí v praxi.
|
| 369 |
+
|
| 370 |
+
---
|
| 371 |
+
|
| 372 |
+
## 4. Prvé slovo môže byť nezmysel. Pridaj warmup prefix.
|
| 373 |
+
|
| 374 |
+
Generovanie "Slovenský jazyk je úradný..." občas produkovalo "Zvolenský jazyk..." — model prvý token po referenci zmenil. Niekedy bolo celé prvé slovo tichý šum.
|
| 375 |
+
|
| 376 |
+
Toto je "warmup" artefakt: model musí prejsť z prozódie referenčného hlasu na vlastnú generáciu a tých prvých ~0,3 s je miesto, kde môže zakolísať. Ťažké slová na pozícii zero ho zasiahnu najsilnejšie.
|
| 377 |
+
|
| 378 |
+
Dva fixy, oba fungujú:
|
| 379 |
+
|
| 380 |
+
**Preformulovať.** Ak "Slovenský" model rozhodí, začni "Slovenčina" namiesto toho. Ľahké, zadarmo, nie vždy stačí.
|
| 381 |
+
|
| 382 |
+
**Pridať warmup prefix.** Daj na začiatok krátku, ľahkú frázu, na ktorej model dokáže pristáť čisto:
|
| 383 |
+
|
| 384 |
+
```
|
| 385 |
+
Vitajte v ukážke.
|
| 386 |
+
Slovenčina je úradný jazyk Slovenskej republiky.
|
| 387 |
+
...
|
| 388 |
+
```
|
| 389 |
+
|
| 390 |
+
Kým model dôjde k slovu "Slovenčina", už sa stabilizoval. Prefix sa stane súčasťou generácie, ale je krátky a prirodzený, a vždy ho môžeš orezať v post-processingu, ak ho nechceš.
|
| 391 |
+
|
| 392 |
+
Toto nie je špecifické len pre Chatterbox — väčšina autoregressive TTS modelov má warmup správanie na úplnom začiatku. Fix sa prenáša.
|
| 393 |
+
|
| 394 |
+
---
|
| 395 |
+
|
| 396 |
+
## 5. Model nevie nahlas čítať názvy jednotlivých písmen
|
| 397 |
+
|
| 398 |
+
Skúšal som vygenerovať vetu "Má bohatú gramatiku, sedem pádov a špecifické hlásky ako ô, ľ alebo ŕ." — vetu, ktorá menuje jednotlivé slovenské písmená. Model produkoval nezmysel pre časť s názvami písmen.
|
| 399 |
+
|
| 400 |
+
Toto je známa limitácia TTS modelov trénovaných na bežnej hovorenej reči: zriedka videli "písmeno ô" ako frázu, takže nevedia, že sa má vysloviť ako názov, nie ako zvuk. To isté platí pre skratky ("NDA" sa prečíta ako "enda") a jednotky ("20 %" sa občas zmení na "two-hundred percent" kvôli tomu, ako boli digit-percent páry tokenizované v tréningových dátach).
|
| 401 |
+
|
| 402 |
+
Riešenie je text normalizácia *pred* TTS. V mojej pipeline mám malý slovensky-špecifický preprocessor, ktorý prepisuje:
|
| 403 |
+
|
| 404 |
+
- `20 %` → `dvadsať percent`
|
| 405 |
+
- `Y100` → `ypsilon sto`
|
| 406 |
+
- `NDA` → `eN-Dý-Á`
|
| 407 |
+
- Názvy písmen → vypísané fonetické formy
|
| 408 |
+
|
| 409 |
+
Žije to ako preprocessing layer, nie ako súčasť modelu. Je ľahšie opraviť text raz, ako pretrénovať model aby zvládal každý edge case.
|
| 410 |
+
|
| 411 |
+
---
|
| 412 |
+
|
| 413 |
+
## 6. `max_new_tokens` má význam pri dlhých generáciách
|
| 414 |
+
|
| 415 |
+
Chatterbox auto-scaluje generation budget:
|
| 416 |
+
|
| 417 |
+
```python
|
| 418 |
+
_max_toks = max_new_tokens or min(4096, max(1000, len(text) * 8))
|
| 419 |
+
```
|
| 420 |
+
|
| 421 |
+
Pre 350-znakový text to dá 2800 tokenov, čo znie ako dosť (pri ~25 Hz token rate je to vyše 100 sekúnd audia). Ale model môže EOS-nuť skoro na konkrétnom slove — aj s budgetom oveľa väčším, ako text potrebuje. Mal som 30-sekundovú naratívnu vetu, ktorej posledné slovo ("Amerike") bolo orezané napriek 4096-tokenovému budgetu.
|
| 422 |
+
|
| 423 |
+
Keď máš dlhý vstup, **nastav `max_new_tokens=4096` explicitne** a v post-processingu kontroluj predčasný EOS. Ak ti výstup končí v polovici slova, ber to ako zlyhanie generácie a skús znova s iným seedom (pozri #3).
|
| 424 |
+
|
| 425 |
+
Pre veľmi dlhé vstupy je spoľahlivejšia stratégia chunkovať na vety, generovať každú samostatne a spojiť s krátkym crossfade. Chatterbox zatiaľ nemá first-class chunkovanie, takže to robíš na úrovni aplikácie.
|
| 426 |
+
|
| 427 |
+
---
|
| 428 |
+
|
| 429 |
+
## 7. Použi `prepare_conditionals` oddelene od `generate`
|
| 430 |
+
|
| 431 |
+
Chatterbox API podporuje predanie `audio_prompt_path=` priamo do `generate()`, ale v produkčnom loope, kde generuješ veľa segmentov s tým istým hlasom, je rýchlejšie zavolať `prepare_conditionals` raz a používať opakovane:
|
| 432 |
+
|
| 433 |
+
```python
|
| 434 |
+
model.prepare_conditionals(reference_path)
|
| 435 |
+
|
| 436 |
+
# Teraz generuj koľkokoľvek bez opätovného načítavania referencie
|
| 437 |
+
for text in texts:
|
| 438 |
+
wav = model.generate(text=text, language_id="sk")
|
| 439 |
+
```
|
| 440 |
+
|
| 441 |
+
Conditioning extrahuje features speaker identity z referencie. Robiť to raz amortizuje cenu cez celý loop. Pre jednorazové demá na tom nezáleží; pre batch joby to môže ušetriť poznateľný čas.
|
| 442 |
+
|
| 443 |
+
Súvisiaca chyba: ak meníš referenčný hlas v polovici loopu, nezabudni znova spustiť `prepare_conditionals` (alebo nullnúť `model.conds`) pred ďalšou generáciou, lebo budeš ďalej klonovať predošlý hlas.
|
| 444 |
+
|
| 445 |
+
---
|
| 446 |
+
|
| 447 |
+
## Finálny recept
|
| 448 |
+
|
| 449 |
+
Dať to dohromady — inference snippet, ktorý by som dal niekomu, kto začína odznova:
|
| 450 |
+
|
| 451 |
+
```python
|
| 452 |
+
import torch, torchaudio, subprocess
|
| 453 |
+
from chatterbox.mtl_tts import ChatterboxMultilingualTTS
|
| 454 |
+
from safetensors.torch import load_file
|
| 455 |
+
|
| 456 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 457 |
+
|
| 458 |
+
# 1. Vyčisti referenciu
|
| 459 |
+
subprocess.run([
|
| 460 |
+
"ffmpeg", "-y", "-i", "reference.wav",
|
| 461 |
+
"-af",
|
| 462 |
+
"highpass=f=70,afftdn=nr=12,lowpass=f=11000,"
|
| 463 |
+
"equalizer=f=6800:t=q:w=1.2:g=-1.5,"
|
| 464 |
+
"silenceremove=start_periods=1:start_silence=0.04:start_threshold=-50dB,"
|
| 465 |
+
"areverse,silenceremove=start_periods=1:start_silence=0.06:start_threshold=-46dB,"
|
| 466 |
+
"areverse",
|
| 467 |
+
"reference_clean.wav",
|
| 468 |
+
], check=True)
|
| 469 |
+
|
| 470 |
+
# 2. Načítaj base + patchni svoj fine-tune
|
| 471 |
+
model = ChatterboxMultilingualTTS.from_pretrained(device=device)
|
| 472 |
+
state = load_file("my_finetune_t3.safetensors", device="cpu")
|
| 473 |
+
# vocab resize blok z #1 sem
|
| 474 |
+
model.t3.load_state_dict(state, strict=True)
|
| 475 |
+
model.t3.to(device).eval()
|
| 476 |
+
|
| 477 |
+
# 3. Priprav referenciu raz
|
| 478 |
+
model.prepare_conditionals("reference_clean.wav")
|
| 479 |
+
|
| 480 |
+
# 4. Generuj s retry
|
| 481 |
+
text = "Vitajte v ukážke. " + your_actual_text # warmup prefix z #4
|
| 482 |
+
RETRY_SEEDS = [42, 0, 123, 7, 99]
|
| 483 |
+
min_dur = max(0.3, len(text) / 25.0)
|
| 484 |
+
|
| 485 |
+
wav = None
|
| 486 |
+
for seed in RETRY_SEEDS:
|
| 487 |
+
torch.manual_seed(seed)
|
| 488 |
+
with torch.inference_mode():
|
| 489 |
+
candidate = model.generate(text=text, language_id="sk", max_new_tokens=4096)
|
| 490 |
+
if candidate.shape[-1] / model.sr >= min_dur:
|
| 491 |
+
wav = candidate
|
| 492 |
+
break
|
| 493 |
+
|
| 494 |
+
torchaudio.save("output.wav", wav.cpu(), model.sr)
|
| 495 |
+
```
|
| 496 |
+
|
| 497 |
+
Toto je zhruba to, čo dnes beží v mojej pipeline.
|
| 498 |
+
|
| 499 |
+
---
|
| 500 |
+
|
| 501 |
+
## Čo nefungovalo
|
| 502 |
+
|
| 503 |
+
Pár vecí, ktoré som skúsil a ukázali sa ako slepá ulička, pre prípad že by ťa lákali:
|
| 504 |
+
|
| 505 |
+
- **Agresívne denoising** referencie (FFT noise reduction pri -18 dB alebo viac). Spoľahlivo odstráni hum, ale začne produkovať kovový, "phasey" klonovaný hlas. -12 dB je sweet spot.
|
| 506 |
+
- **`temperature=0.4` alebo nižšie**. Sploští prozódiu do bodu, kde to znie ako automat z call centra.
|
| 507 |
+
- **Vynechať warmup prefix a orezať prvých 0,3 s v post-processingu**. Funguje *väčšinou*, ale občas odreže začiatok skutočne čistého prvého slova. Prefix je spoľahlivejší.
|
| 508 |
+
- **Pokus opraviť EOS-early problém cez `repetition_penalty=1.5` alebo viac**. Nepomohlo; rozhodnutie modelu zastaviť je upstream od repetition logiky.
|
| 509 |
+
|
| 510 |
+
---
|
| 511 |
+
|
| 512 |
+
## Záverom
|
| 513 |
+
|
| 514 |
+
Ak fine-tunuješ Chatterbox na jazyk, ktorý nepodporuje, najväčšie veci ktoré môžeš spraviť *mimo* trénovacieho loopu sú:
|
| 515 |
+
|
| 516 |
+
1. Vyčistiť reference audio
|
| 517 |
+
2. Tunovať generation params (alebo akceptovať trade-offs defaultov)
|
| 518 |
+
3. Normalizovať text *predtým*, než sa dostane k modelu
|
| 519 |
+
4. Použiť warmup prefix pre prvé slovo
|
| 520 |
+
5. Nastaviť `max_new_tokens` explicitne a mať retry path
|
| 521 |
+
|
| 522 |
+
Slovenský fine-tune žije na [huggingface.co/pekiskol/chatterbox-tts-slovak](https://huggingface.co/pekiskol/chatterbox-tts-slovak) pod MIT — vlož inference snippet vyššie a malo by to fungovať out of the box. Spätná väzba (alebo fine-tunes na iných jazykoch ktoré narazili na rovnaké veci) vítaná v HF discussions tab modelu.
|
| 523 |
+
|
| 524 |
+
Ak si objavil iné Chatterbox tuning triky ktoré som tu nespomenul, napíš komentár — rád by som ten zoznam doplnil.
|
| 525 |
+
|
| 526 |
+
---
|
| 527 |
+
|
| 528 |
+
*Kód v tomto poste je tiež v [release scriptoch](https://huggingface.co/pekiskol/chatterbox-tts-slovak/tree/main) na stránke modelu.*
|
sk/chatterbox-tts-slovak/README.md
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- sk
|
| 5 |
+
library_name: chatterbox
|
| 6 |
+
pipeline_tag: text-to-speech
|
| 7 |
+
tags:
|
| 8 |
+
- text-to-speech
|
| 9 |
+
- tts
|
| 10 |
+
- voice-cloning
|
| 11 |
+
- chatterbox
|
| 12 |
+
- slovak
|
| 13 |
+
- slovenčina
|
| 14 |
+
- sk
|
| 15 |
+
base_model: ResembleAI/chatterbox
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# Chatterbox TTS — Slovak fine-tune
|
| 19 |
+
|
| 20 |
+
Slovak (slovenčina) fine-tune of [Resemble AI's Chatterbox Multilingual TTS](https://huggingface.co/ResembleAI/chatterbox).
|
| 21 |
+
Drop-in T3 replacement weights — load the base `ChatterboxMultilingualTTS`,
|
| 22 |
+
then swap in these Slovak weights to get high-quality Slovak speech with
|
| 23 |
+
zero-shot voice cloning.
|
| 24 |
+
|
| 25 |
+
📝 **Tuning guide**: a 7-lessons writeup on fine-tuning Chatterbox for a
|
| 26 |
+
low-resource language is also published on dev.to:
|
| 27 |
+
[Fine-tuning Chatterbox on a Low-Resource Language: 7 Things That Mattered](https://dev.to/pekisko/fine-tuning-chatterbox-on-a-low-resource-language-7-things-that-mattered-13e1)
|
| 28 |
+
(or see [`GUIDE.md`](GUIDE.md) in this repo for the bilingual EN+SK version).
|
| 29 |
+
|
| 30 |
+
> 🇸🇰 **Slovenčina dole** (Slovak description below).
|
| 31 |
+
|
| 32 |
+
---
|
| 33 |
+
|
| 34 |
+
## What's in this repo
|
| 35 |
+
|
| 36 |
+
| File | Size | What it is |
|
| 37 |
+
|------|------|------------|
|
| 38 |
+
| `t3_sk_v2.2.safetensors` | ~2 GB | Slovak T3 weights — production default |
|
| 39 |
+
| `GUIDE.md` | ~12 KB | Practical tuning guide — 7 lessons from fine-tuning Chatterbox on a low-resource language (EN + SK) |
|
| 40 |
+
|
| 41 |
+
This repo ships **only model weights** plus a few demo samples. You bring your
|
| 42 |
+
own reference audio (3–10 s of clean Slovak speech) for voice cloning at
|
| 43 |
+
inference time.
|
| 44 |
+
|
| 45 |
+
## Demo samples
|
| 46 |
+
|
| 47 |
+
Generated with a Common Voice SK reference clip (CC-0). Reference audio not
|
| 48 |
+
included — only model output.
|
| 49 |
+
|
| 50 |
+
**Greeting** — *Dobrý deň, vitajte v ukážke slovenského syntetického hlasu.*
|
| 51 |
+
|
| 52 |
+
<audio controls src="https://huggingface.co/pekiskol/chatterbox-tts-slovak/resolve/main/samples/01_greeting.wav"></audio>
|
| 53 |
+
|
| 54 |
+
**Narrative** — *V Bratislave práve začína nový deň. Slnko vychádza nad Dunajom a mesto sa pomaly prebúdza.*
|
| 55 |
+
|
| 56 |
+
<audio controls src="https://huggingface.co/pekiskol/chatterbox-tts-slovak/resolve/main/samples/02_narrative.wav"></audio>
|
| 57 |
+
|
| 58 |
+
**Explanation** — *Tento model dokáže klonovať akýkoľvek hlas iba z niekoľkých sekúnd referenčnej nahrávky.*
|
| 59 |
+
|
| 60 |
+
<audio controls src="https://huggingface.co/pekiskol/chatterbox-tts-slovak/resolve/main/samples/03_explanation.wav"></audio>
|
| 61 |
+
|
| 62 |
+
**Long narrative (~30 s)** — short text on Slovak language and its history (showcases prosody over a longer span).
|
| 63 |
+
|
| 64 |
+
<audio controls src="https://huggingface.co/pekiskol/chatterbox-tts-slovak/resolve/main/samples/04_long_narrative.wav"></audio>
|
| 65 |
+
|
| 66 |
+
## Requirements
|
| 67 |
+
|
| 68 |
+
```bash
|
| 69 |
+
pip install chatterbox-tts torch torchaudio safetensors
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
GPU recommended (~3.5 GB VRAM). Runs on CPU but slowly.
|
| 73 |
+
|
| 74 |
+
## Quickstart
|
| 75 |
+
|
| 76 |
+
```python
|
| 77 |
+
import torch
|
| 78 |
+
from huggingface_hub import hf_hub_download
|
| 79 |
+
from safetensors.torch import load_file
|
| 80 |
+
from chatterbox.mtl_tts import ChatterboxMultilingualTTS
|
| 81 |
+
|
| 82 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 83 |
+
|
| 84 |
+
# 1) Load the base multilingual Chatterbox
|
| 85 |
+
model = ChatterboxMultilingualTTS.from_pretrained(device=device)
|
| 86 |
+
|
| 87 |
+
# 2) Download Slovak T3 weights and patch them in
|
| 88 |
+
sk_weights = hf_hub_download(
|
| 89 |
+
repo_id="pekiskol/chatterbox-tts-slovak",
|
| 90 |
+
filename="t3_sk_v2.2.safetensors",
|
| 91 |
+
)
|
| 92 |
+
state = load_file(sk_weights, device="cpu")
|
| 93 |
+
|
| 94 |
+
# Handle vocab size mismatch between SK fine-tune and base model
|
| 95 |
+
target_vocab = model.t3.text_emb.weight.shape[0]
|
| 96 |
+
src_vocab = state["text_emb.weight"].shape[0]
|
| 97 |
+
if src_vocab > target_vocab:
|
| 98 |
+
state["text_emb.weight"] = state["text_emb.weight"][:target_vocab, :]
|
| 99 |
+
state["text_head.weight"] = state["text_head.weight"][:target_vocab, :]
|
| 100 |
+
elif src_vocab < target_vocab:
|
| 101 |
+
pad = target_vocab - src_vocab
|
| 102 |
+
emb_pad = state["text_emb.weight"].mean(dim=0, keepdim=True).repeat(pad, 1)
|
| 103 |
+
head_pad = state["text_head.weight"].mean(dim=0, keepdim=True).repeat(pad, 1)
|
| 104 |
+
state["text_emb.weight"] = torch.cat([state["text_emb.weight"], emb_pad], dim=0)
|
| 105 |
+
state["text_head.weight"] = torch.cat([state["text_head.weight"], head_pad], dim=0)
|
| 106 |
+
|
| 107 |
+
model.t3.load_state_dict(state, strict=True)
|
| 108 |
+
model.t3.to(device).eval()
|
| 109 |
+
|
| 110 |
+
# 3) Generate Slovak speech with zero-shot voice cloning
|
| 111 |
+
wav = model.generate(
|
| 112 |
+
text="Ahoj, toto je ukážka slovenského hlasu generovaného modelom Chatterbox.",
|
| 113 |
+
audio_prompt_path="path/to/your/reference.wav", # 3–10 s of clean SK speech
|
| 114 |
+
language_id="sk",
|
| 115 |
+
)
|
| 116 |
+
|
| 117 |
+
import torchaudio
|
| 118 |
+
torchaudio.save("output.wav", wav, model.sr)
|
| 119 |
+
```
|
| 120 |
+
|
| 121 |
+
## Tips for good results
|
| 122 |
+
|
| 123 |
+
- **Reference audio**: 4–6 seconds of clean, dense speech works best. Avoid music,
|
| 124 |
+
noise, and long silences.
|
| 125 |
+
- **Text length**: split very long inputs into sentences or short paragraphs; the
|
| 126 |
+
model can lose coherence on overly long generations.
|
| 127 |
+
- **Numbers and abbreviations**: Slovak numbers, units (e.g. `20 %`, `Y100`) and
|
| 128 |
+
acronyms (e.g. `NDA`) are sometimes mispronounced. For production use, normalise
|
| 129 |
+
text first (write `dvadsať percent` instead of `20 %`, `eN-Dý-Á` instead of `NDA`).
|
| 130 |
+
|
| 131 |
+
## Limitations
|
| 132 |
+
|
| 133 |
+
- Slovak only — for other languages use the original Chatterbox Multilingual.
|
| 134 |
+
- Quality depends heavily on the reference audio.
|
| 135 |
+
- Code-switching (mixing Slovak with English in one sentence) can produce wrong
|
| 136 |
+
pronunciation on the foreign words.
|
| 137 |
+
- The model can occasionally produce quiet, garbled audio mid-utterance on hard
|
| 138 |
+
inputs; usually fixed by re-generating or splitting the text.
|
| 139 |
+
|
| 140 |
+
## License
|
| 141 |
+
|
| 142 |
+
This fine-tune is released under the **MIT License**, matching the base
|
| 143 |
+
[Chatterbox](https://huggingface.co/ResembleAI/chatterbox) license. You are free
|
| 144 |
+
to use it commercially.
|
| 145 |
+
|
| 146 |
+
When using this model, please credit:
|
| 147 |
+
- This fine-tune (link to this repo)
|
| 148 |
+
- [Resemble AI Chatterbox](https://huggingface.co/ResembleAI/chatterbox) (base model)
|
| 149 |
+
|
| 150 |
+
## Citation
|
| 151 |
+
|
| 152 |
+
If this model is useful in your work, a citation/credit is appreciated:
|
| 153 |
+
|
| 154 |
+
```bibtex
|
| 155 |
+
@misc{chatterbox-tts-slovak,
|
| 156 |
+
author = {pekiskol},
|
| 157 |
+
title = {Chatterbox TTS — Slovak fine-tune},
|
| 158 |
+
year = {2026},
|
| 159 |
+
url = {https://huggingface.co/pekiskol/chatterbox-tts-slovak}
|
| 160 |
+
}
|
| 161 |
+
```
|
| 162 |
+
|
| 163 |
+
---
|
| 164 |
+
|
| 165 |
+
## 🇸🇰 Po slovensky
|
| 166 |
+
|
| 167 |
+
Toto je fine-tune modelu [Chatterbox Multilingual TTS](https://huggingface.co/ResembleAI/chatterbox)
|
| 168 |
+
od Resemble AI, dotrénovaný na slovenčinu. Použitie:
|
| 169 |
+
|
| 170 |
+
1. Načítaš základný `ChatterboxMultilingualTTS` z Resemble AI.
|
| 171 |
+
2. Nahradíš T3 weights tými zo súboru `t3_sk_v2.2.safetensors`.
|
| 172 |
+
3. Generuješ slovenskú reč s **zero-shot klonovaním hlasu** — model skopíruje
|
| 173 |
+
farbu hlasu z 3–10 sekundovej referenčnej nahrávky, ktorú dodáš.
|
| 174 |
+
|
| 175 |
+
**Licencia:** MIT — komerčné použitie povolené, stačí pri publikovaní uviesť
|
| 176 |
+
odkaz na tento model aj na základný Chatterbox.
|
| 177 |
+
|
| 178 |
+
**Reference audio:** repo neobsahuje žiadne hlasové vzorky. Vlastný hlas
|
| 179 |
+
(alebo hlas s explicitným súhlasom) si dodáš ty pri inferencii.
|
sk/chatterbox-tts-slovak/samples/01_greeting.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:08dc95fc54df891f0bd6a79d543ee5f6b7272b89a15d2c98df842fe00d52fa4d
|
| 3 |
+
size 410960
|
sk/chatterbox-tts-slovak/samples/02_narrative.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:51bccb727c89ddb96b07dee9d7712ae4a26de2a92a1dd3f71e0e5a53adac613e
|
| 3 |
+
size 633680
|
sk/chatterbox-tts-slovak/samples/03_explanation.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e327b98d6ef9d70768217c9ae6a43370c1970394057f6cacd3b51d05436b8eeb
|
| 3 |
+
size 572240
|
sk/chatterbox-tts-slovak/samples/04_long_narrative.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a21b3ff487f642c7bd2d73940eb46dc391949566c306fb92887e13c5d9a99616
|
| 3 |
+
size 2809040
|
sk/chatterbox-tts-slovak/source.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
https://huggingface.co/pekiskol/chatterbox-tts-slovak
|
sk/chatterbox-tts-slovak/t3_sk_v2.2.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:aaeef4d1e990715ce8c383d73efed89fae52a55de653a9ba2674284ebb150bcd
|
| 3 |
+
size 2143989752
|