File size: 5,422 Bytes
d4101a0 | 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 | # Fine-Tuning Guide (New PT-BR Speaker or Domain)
Because **Lua Nova V1** predicts spectrograms in BigVGAN's universal **24 kHz 100-band Slaney log-mel space**, adapting to a new Brazilian Portuguese speaker or speaking style is fast and does **not** require training a vocoder from scratch.
---
## Requirements
- **GPU:** NVIDIA GPU with `6–8 GB` VRAM (`CFM` training uses `< 3.5 GB`; optional `Option B` vocoder adaptation on `BigVGAN-base` uses `~6.8 GB`).
- **Audio Data:**
- **Minimum:** `30–60 minutes` of clean `24 kHz` mono speech (single speaker, quiet studio or denoised).
- **Recommended:** `2–4 hours` for maximum voice likeness and prosody stability.
- **Estimated Time (RTX 4070 class GPU):**
- Data preparation + CTC alignment: `~3–6 min` for 1h of audio
- Acoustic CFM adaptation (`10k–15k` steps): `~15–22 min`
- *(Optional)* Gentle BigVGAN-base Option B polish (`1k–2k` steps): `~8–15 min`
---
## 1. Prepare Your Dataset Manifest
Create two manifests (`train.jsonl` and `validation.jsonl`) with **no overlapping text or IDs** between splits. Paths in `audio` are resolved relative to the JSONL file:
```json
{"id": "utt_0001", "text": "Olá, esta é uma frase de teste em português.", "voice_id": "F1", "audio": "wavs/utt_0001.wav"}
```
> Resample all WAVs explicitly to **24,000 Hz mono PCM** beforehand (`ffmpeg -i in.wav -ar 24000 -ac 1 out.wav`). Keep peak amplitude $\le 1.0$.
> **Speaker ID tip:** For single-speaker fine-tuning starting from our pretrained checkpoint, keeping `"voice_id": "F1"` reuses existing speaker embeddings directly without resizing model parameters.
---
## 2. Extract Acoustic Features & Forced Alignments
```bash
# Step A: Acoustic feature extraction (wave, 80-mel, F0 pitch via Parselmouth, RMS energy)
uv run lua-nova-prepare --inputs data/raw/train.jsonl --split train --output data/features
uv run lua-nova-prepare --inputs data/raw/validation.jsonl --split validation --output data/features
# Step B: Forced alignment via pretrained wav2vec2 CTC espeak recognizer
uv run lua-nova-annotate \
--features data/features \
--output data/annotations \
--dataset-revision my-voice-v1 \
--device cuda \
--refine 2 --stage refined-2
```
> Both steps are resumable via `--resume`. Alignments check phoneme rate, vowel voicing, and silence pauses automatically, writing rejected outliers to `rejected.jsonl`.
---
## 3. Fine-Tune `LuaNovaCFM v5` on Your Voice
Start directly from the pretrained `cfm_v5_soup50.pt` checkpoint downloaded from Hugging Face:
```bash
uv run lua-nova-train-cfm \
--train data/annotations/train.jsonl \
--validation data/annotations/validation.jsonl \
--init-cfm checkpoints/cfm_v5_soup50.pt \
--no-freeze-frontend \
--output runs/my_voice_cfm \
--steps 12000 \
--lr 1.5e-4 --min-lr 1e-5 --warmup 300 \
--save-every 3000 --val-every 500 \
--device cuda
```
- Use `--no-freeze-frontend` when adapting timbre **plus** speaking cadence/pitch range to a brand-new speaker.
- Use `--freeze-frontend` if your voice has very few minutes (`< 45 min`) or matches existing speaking cadence closely and only needs acoustic timbre tuning.
*(Optional)* If your voice expresses notably different intonation patterns (questions, pauses, stress shifts), run a short ProsodyFlow stage first before `lua-nova-train-cfm`:
```bash
uv run lua-nova-train-prosody \
--train data/annotations/train.jsonl \
--validation data/annotations/validation.jsonl \
--init-cfm checkpoints/cfm_v5_soup50.pt \
--output runs/my_voice_prosody \
--steps 4000 --eval-every 1000 --save-every 2000 --device cuda
```
---
## 4. *(Optional)* Option A + Option B Final Polish
Once `runs/my_voice_cfm/inference_v5_ema.pt` converges, you can optionally remove subtle acoustic-vocoder mismatch:
1. **Option A (E2E through frozen BigVGAN + frozen NVIDIA MIT discriminators):**
```bash
uv run lua-nova-train-e2e \
--train data/annotations/train.jsonl \
--validation data/annotations/validation.jsonl \
--init-v5 runs/my_voice_cfm/inference_v5_ema.pt \
--output runs/my_voice_optA \
--steps 1500 --save-steps 1000 1500 --device cuda
```
And create a 50/50 weight soup in Python:
```python
from lua_nova_v1.utils import soup_checkpoints
soup_checkpoints(
"runs/my_voice_cfm/inference_v5_ema.pt",
"runs/my_voice_optA/inference_v5_e2e_step-001500.pt",
"runs/my_voice_optA/inference_v5_soup50.pt",
alpha=0.5,
)
```
2. **Option B (Gentle `BigVGAN-base` FT with NVIDIA 5M-step pretrained discriminators):**
```bash
uv run lua-nova-train-vocoder \
--train data/annotations/train.jsonl \
--validation data/annotations/validation.jsonl \
--cfm-ckpt runs/my_voice_optA/inference_v5_soup50.pt \
--model-id nvidia/bigvgan_base_24khz_100band \
--pretrained-disc --disc-warmup 0 \
--output runs/my_voice_vocoder_optB \
--steps 2000 --save-steps 1000 1500 2000 \
--batch-size 6 --grad-accum 2 --lr-g 1e-5 --lr-d 1e-5 --device cuda
```
---
## 5. Run Inference on Your New Voice
```bash
uv run lua-nova-speak \
--text "Minha nova voz em português está pronta para falar!" \
--out test_voice.wav \
--cfm runs/my_voice_optA/inference_v5_soup50.pt \
--vocoder runs/my_voice_vocoder_optB/bigvgan_ft_step-002000.pt \
--device cpu
```
|