tiny-voca-da / recipe /scripts /post_trim_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
3.66 kB
#!/usr/bin/env bash
# Next GPU jobs after the user's listening verdict (2026-11-25, ~09:00 UTC): #4 (v3-trim) is the
# best, but "long vowels have this robotic sound". That is the pulse-train buzz that
# tiny-voca-it fixed with its "vocoder-two" recipe (tiny-voca/docs/analysis/quality-journey.md
# §6.4-6.6; scripts/training/round5.sh, round6.sh), preferred blind on both voices there.
# Run detached in the v3 image:
# docker compose run -d --name tiny-voca-dk-post-trim kit-v3 \
# bash -c "bash scripts/post_trim_chain.sh > checks/post-trim-chain.log 2>&1"
# GPU 1 (v2-trim paused with runs/v2trim-en-gan/STOP; resumable): the vocoder continues from
# runs/vocoder-da-prior/last.pt (52.1k, same 300k schedule) with the high-band prior (pulse
# share x0.05 from 2.5 kHz, full effect at 5 kHz), the share randomised per utterance in
# [0, 0.1] so it can be tuned per voice at inference without leaving the training
# distribution, and mel weight 15 instead of 45. No vocoder pairs (dropped in vocoder-two).
# GPU 0 (when v3-trim reaches 100k): export, then v3-trim 100k -> 130k with vocos_mel_loss 10.
# Stop cleanly: touch runs/v3trim-vml/STOP (voice). The vocoder has no stop file: stop its
# process right after a save (every 2000 steps); this script resumes it on a rerun.
set -uo pipefail
cd /opt/kit
stamp() { echo "== stage $1 $(date -u +%FT%TZ)"; }
fail() { echo "exit=1 stage=$1"; exit 1; }
wait_for() { # log, pattern; gives up if that chain failed
until grep -q "$2" "$1" 2>/dev/null; do
grep -q "^exit=1" "$1" 2>/dev/null && { echo "exit=1 waiting for $1"; exit 1; }
sleep 60; done; }
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 60; done; }
VOICE=models/v3trim-en-gan-s100000.pt
ANN=data/v3trim-prepared/annotations
VOC=runs/vocoder-da-hb
stamp wait-gpu1; wait_for checks/trim-chain.log "^exit="; wait_gpu 1 12e9
stamp vocoder-hb
START=(--init-from runs/vocoder-da-prior/last.pt); [[ -f "$VOC/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 "$VOC" \
--steps 300000 --batch 32 --teacher vocos --distill-mode spectrum --distill-weight 4 \
--device cuda --workers 8 --keep-every 10000 >> "$VOC.log" 2>&1
echo "vocoder exit=$? $(date -u +%FT%TZ)" ) &
stamp wait-v3trim; wait_for checks/v3trim-chain.log "^exit=0"
stamp export
[[ -f "$VOICE" ]] || python tiny-voca/scripts/export_checkpoint.py --checkpoint runs/v3trim-en-gan/last.pt --output "$VOICE" \
|| fail export
stamp vml
python - <<'EOF' || fail vml-config
import json
c = json.load(open('data/v3trim-prepared/config.da.json'))
c['vocos_mel_loss'] = 10.0
json.dump(c, open('work/config.v3trim-vml.json', 'w'), indent=2)
EOF
START=(--init-from runs/v3trim-en-gan/last.pt); [[ -f runs/v3trim-vml/last.pt ]] && START=(--resume runs/v3trim-vml/last.pt)
CUDA_VISIBLE_DEVICES=0 python -m tiny_voca.train \
--train "$ANN/train.jsonl" --validation "$ANN/validation.jsonl" \
--config work/config.v3trim-vml.json --output runs/v3trim-vml --device cuda \
--steps 130000 --batch-frames 9000 --max-batch 32 \
--gan-start 8000 --gan-ratio 0.7 --teacher-final 0 \
--save-every 1000 --keep-every 10000 --log-every 50 \
--max-seconds inf --stop-file runs/v3trim-vml/STOP "${START[@]}" \
>> runs/v3trim-vml.log 2>&1 || fail vml
wait
echo exit=0