tiny-voca-da / recipe /scripts /pairs_chain.sh
inlanger's picture
tiny-voca-da v0.1: frontend v4 + sm9 vocoder (ONNX fp32/int8, PyTorch, frontend, recipe, samples)
adabee1 verified
Raw History Blame Contribute Delete
2.34 kB
#!/usr/bin/env bash
# Vocoder fine-tune on the voice model's own spectrograms ("pairs"), started 2026-11-25 ~13:30 UTC.
# Why (AGENTS.md "Round 4"): teacher-forced synthesis (scripts/tf_synth.py) puts the remaining
# 1-2 kHz buzz mostly in the voice model's spectrogram. Even Vocos (13.5M) locks 0.54 on it
# against 0.38 on the real one; our vocoder 0.53 vs 0.46. The standard two-stage remedy
# (tiny-voca-it quality-journey §6.2): teach the vocoder "model spectrogram -> real recording".
# 1. pairs from v3trim 100k on the voice training clips (real durations/pitch/energy);
# 2. once GPU 1 is free (runs/vocoder-da-hb is paused after a save; resumable with
# --resume), fine-tune from its last.pt with the same high-band flags, 70% of paired
# crops on the model spectrogram, the cosine schedule ending at 112k (+~20k steps).
# Run detached in the v3 image:
# docker compose run -d --name tiny-voca-dk-pairs kit-v3 \
# bash -c "bash scripts/pairs_chain.sh > checks/pairs-chain.log 2>&1"
set -uo pipefail
cd /opt/kit
stamp() { echo "== stage $1 $(date -u +%FT%TZ)"; }
fail() { echo "exit=1 stage=$1"; exit 1; }
wait_gpu() { # device index, free bytes needed
until CUDA_VISIBLE_DEVICES=$1 python -c "import sys, torch; sys.exit(0 if torch.cuda.mem_get_info(0)[0] > $2 else 1)" 2>/dev/null
do sleep 30; done; }
VOICE=models/v3trim-en-gan-s100000.pt
PAIRS=data/vocoder-pairs-v3trim100k
OUT=runs/vocoder-da-hb-pairs
stamp pairs
CUDA_VISIBLE_DEVICES=1 python -m tiny_voca.vocoder_pairs --checkpoint "$VOICE" \
--annotations data/v3trim-prepared/annotations/train.jsonl --output "$PAIRS/train" --device cuda || fail pairs
stamp wait-gpu1; wait_gpu 1 14e9
stamp finetune
START=(--init-from runs/vocoder-da-hb/last.pt); [[ -f "$OUT/last.pt" ]] && START=(--resume)
CUDA_VISIBLE_DEVICES=1 python -m tiny_voca.train_vocoder "${START[@]}" --prior --prior-high-hz 2500 --prior-high-gain 0.05 \
--prior-gain-range 0.0 0.1 --mel-weight 15 \
--manifests data/full-features/train.jsonl --validation data/full-features/validation.jsonl --output "$OUT" \
--steps 112000 --batch 32 --teacher vocos --distill-mode spectrum --distill-weight 4 \
--pairs "$PAIRS/train/pairs.jsonl" --pair-fraction 0.7 \
--device cuda --workers 8 --save-every 1000 --keep-every 5000 >> "$OUT.log" 2>&1 || fail finetune
echo exit=0