DEV Community

Practical Guide to Fine-Tuning Speech Models: From Data Cleaning to ASR/TTS Deployment (with Whisper, Fun-ASR, GPT-SoVITS)

General-purpose speech models work out of the box, but the moment they encounter industry jargon, regional accents, proprietary product names, or a fixed voice, they start "hallucinating" or going off-key.

Fine-tuning isn't magic - it boils down to three core things: getting the data alignment clean, choosing the right freezing strategy, andη΄§η›― (keeping a close eye on) validation metrics. Below, we break it down in engineering deployment order, providing reproducible configurations for both ASR and TTS pipelines.

I. First, Clarify What You're Fine-Tuning

  • ASR (Automatic Speech Recognition): Audio β†’ Text. Representatives: Whisper, Fun-ASR-Nano, Qwen-Audio, etc.
  • TTS / Voice Cloning (Speech Synthesis): Text + Reference Audio β†’ Audio. Representatives: GPT-SoVITS, Qwen3-TTS, ChatTTS, VITS family.
  • End-to-End Speech Large Models: Unified modeling of audio tokens ↔ text tokens. During fine-tuning, usually only the adapter or LLM intermediate layers are modified.

For model selection, don't jump straight to full-parameter fine-tuning. For <100 hours of domain data, prioritize LoRA / Adapter / only unfreezing the decoder; consider full-parameter tuning only when data exceeds 10,000 hours.

II. Data Preparation: Determines 80% of the Ceiling

ASR Data Checklist (JSONL or two-column CSV):

{"audio": "data/001.wav", "sr": 16000, "duration": 6.2, "text": "Send me the X7-Pro spec sheet via email", "domain": "erp_order", "speaker": "sp_023"}

Hard rules:

  • Unified 16 kHz mono. Use the model's built-in log_mel_spectrogram; don't calculate mel manually with librosa.
  • Single clip ≀ 30 s (Whisper window); cut long audio at natural pauses.
  • Trim leading/trailing silence, double-label + spot-check, manually verify alignment for 10 random clips - misalignment is more fatal than poor hyperparameters.
  • Domain data : General data β‰ˆ 7:3 mix, to prevent "forgetting how to speak."
  • 10 hours is the starting point; 30+ hours brings a performance leap; for <10 hours, freeze the encoder and only train the decoder.

TTS / Cloning Data:

  • 1-30 min of clean dry vocals per speaker for zero-shot trial; 1.5-3 hours of fine-tuning is needed to stably beat zero-shot similarity.
  • Long audio β†’ UVR to remove BGM β†’ cut into 3-10 s segments β†’ ASR for labeling β†’ manual correction of typos (typos = voice drift).
  • Annotation format: audio|speaker|lang|text, use zh/en/ja/ko/yue for lang.
  • For speaker embedding, don't use a single reference clip; take the centroid of 64 embeddings, boosting cosine similarity from ~0.7 to 0.85+.

III. ASR Fine-Tuning: Two Paths - Whisper & Fun-ASR

Path A: Whisper (Seq2SeqTrainer + LoRA)

Key configuration:

model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-medium")

LoRA only attached to attention q/k/v:

peft_config = LoraConfig(r=16, target_modules=["q_proj","k_proj","v_proj"], lora_dropout=0.05, bias="none")

Small data: freeze encoder, only train decoder + LoRA:

for p in model.model.encoder.parameters():
    p.requires_grad = False
  • lr: Full-parameter 1e-5, LoRA 1e-4; warmup 500-2000 steps + cosine decay
  • bf16/fp16 + gradient checkpointing, effective batch 16-64 (use grad accum to reach)
  • SpecAugment: use conservatively (don't mask too aggressively when domain data is scarce)
  • Metrics: Validation set WER / CER, early stop if no drop for 3 consecutive epochs
  • Vocabulary expansion: After adding new domain tokens to tokenizer, train embedding with a higher lr separately; don't let random initialization drag down convergence

Practical reference: 20h medical dictation fine-tuned on medium, terminology WER 12% β†’ 4.5%; 4h Icelandic fine-tuned on turbo, 18% β†’ 6%.

Path B: Fun-ASR-Nano (ChatML format, full-parameter friendly)

Convert data to ChatML:

{"messages":[ {"role":"system","content":"You are a helpful assistant."}, {"role":"user","content":"Speech transcription:!./audio/001.wav"}, {"role":"assistant","content":"Order has generated a sales order"} ]}

Freezing strategy based on data volume:

  • <1000 h: Only train audio_adaptor
  • <5000 h: Train audio_encoder + audio_adaptor
  • 10000 h: Full-parameter

After training: run decode.py β†’ whisper_mix_normalize.py for inverse normalization β†’ compute-wer.

IV. TTS / Voice Cloning Fine-Tuning: GPT-SoVITS & Qwen3-TTS

GPT-SoVITS Pipeline (WebUI is the easiest):

  1. Split long audio (3-10 s)
  2. Auto-transcribe with faster-whisper / funasr
  3. Manually proofread text (this step determines success or failure)
  4. Format β†’ First train SoVITS (8-16 epochs) β†’ Then train GPT (15-20 epochs)
  5. Output xxx_e10.ckpt + xxx.pth packaged as a voice directory; no need to pass reference audio during inference

Pitfalls:

  • OOM β†’ Reduce batch size or enable is_half
  • Metallic sound β†’ Use v4 (native 48 kHz); v3 has upsampling artifacts
  • One audio clip only learns one "speaking state"; if trained on singing, it will output singing

Qwen3-TTS class (RVQ multi-codebook):

  • Loss = talker loss (codebook 0) + 0.3 Γ— sub-talker loss (layers 1-15)
  • lr ≀ 1e-5, warmup + cosine; flat lr causes early overshooting and late overfitting
  • Bake speaker embedding centroid into checkpoint; TTFA reduced from ~154 ms (ICL) to ~130 ms

Preventing Catastrophic Forgetting (Multi-speaker incremental training):

  • Decouple speaker encoder, freeze backbone and only train embedding / adapter
  • LoRA per-speaker stores matrices, without touching base weights
  • Replay: Mix in 5-10% old speaker samples, or use generative pseudo-replay
  • EWC penalizes key parameter drift

V. Hyperparameter Quick Reference (Single A100/H100 starting point)

  • Item ASR Full-param ASR LoRA TTS Fine-tuning lr: 1e-5 / 1e-4 / ≀1e-5
  • batch (effective): 16-32 / 16-64 / 8-16
  • epoch: 3-8 / 5-10 / 8-20
  • Precision: bf16 / bf16 / fp16/bf16
  • Early Stop: WER no drop / WER no drop / Similarity/MCD no rise
  • Optimizer unified as AdamW, weight_decay 0.01, grad clip 1.0.

VI. Evaluation: Don't Just Look at Loss

ASR: WER/CER (look at by domain subcategory), terminology recall rate, long audio segmentation error rate.

TTS: MOS (human 1-5), speaker similarity (SV system cos), MCD (lower is better), ASR-WER inverse test for intelligibility, RTF/TTFA.

With 1.5h of data fine-tuning Qwen3-TTS, it may not beat zero-shot in similarity/MOS, but it wins in "no need to carry reference audio every time" and more stable batch inference - this is the engineering value of fine-tuning.

VII. Deployment Wrap-up

  • ASR: Export to ONNX / faster-whisper format, quantize to INT8 to compress size to 35%, accuracy drop <2%.
  • TTS: Load voice packs independently, share main model as a singleton, switch via speaker_embedding.
  • Mobile/Edge: TensorRT or MLC-LLM route, 10 MB-level adapter is more realistic than full model.
  • Compliance: Must obtain authorization for real human voices, embed watermarks in synthetic audio, prohibit sensitive scenarios.

One-sentence conclusion: The deciding factor in speech fine-tuning isn't model size, but "10 hours of clean 16 kHz aligned domain data + correct layer freezing + WER/similarity early stopping." Hyperparameters merely cash in the data quality; no matter how fancy the LoRA, it can't save misaligned data.

Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.