#!/usr/bin/env bash # Assemble the Hugging Face release folder on the GPU host (AGENTS.md, "Hugging Face release"). # The release is v4 + sm9: voice models/v4trim-tex1k-s220000.pt and vocoder # models/vocoder-r21-CT4-sm9-s152000.pt, frontend v4. Output: $D/work/hf-release/tiny-voca-da. # cd ~/stacks/tiny-voca-dk && bash scripts/hf_release.sh # Upload separately (token on stdin, never stored): see AGENTS.md. set -euo pipefail D=${DATA_ROOT:-$HOME/models/tiny-voca-dk} S=$(cd "$(dirname "$0")/.." && pwd) N=v4tex1k220k-vocCT4sm9 R=$D/work/hf-release/tiny-voca-da rm -rf "$R"; mkdir -p "$R"/{onnx,pytorch,frontend,samples,eval,recipe} # model card, inference script, licence cp "$S/release/hf/README.md" "$S/release/hf/speak.py" "$R/" cp "$S/kit-v3/licenses/Apache-2.0.txt" "$R/LICENSE" # ONNX (voice + neural vocoder in one graph) and PyTorch weights cp "$D/export/$N.onnx" "$R/onnx/model.onnx"; cp "$D/export/$N.json" "$R/onnx/model.json" cp "$D/export/$N-int8mm.onnx" "$R/onnx/model-int8.onnx"; cp "$D/export/$N-int8mm.json" "$R/onnx/model-int8.json" cp "$D/models/v4trim-tex1k-s220000.pt" "$R/pytorch/voice.pt" cp "$D/models/vocoder-r21-CT4-sm9-s152000.pt" "$R/pytorch/vocoder.pt" # frontend v4: the two patches on tiny-voca-it, the NST G2P package, the profile config cp "$S/kit-v3/patches/danish.patch" "$S/kit-v4/patches/danish-v4.patch" "$R/frontend/" cp "$S/kit-v4/resources/da_g2p_nst_v1.pt" "$S/kit-v4/resources/da_g2p_nst_v1.symbols.json" \ "$S/kit-v4/resources/danish_g2p_data.py" "$R/frontend/" docker run --rm --entrypoint cat tiny-voca-dk:v4 /opt/kit/config.da.json > "$R/frontend/config.da.json" # samples: the 20 probe sentences as rendered for the evaluation, 16-bit, with their texts cp "$S/kit-v3/probes_da.jsonl" "$R/samples/probes_da.jsonl" docker run --rm --user "$(id -u):$(id -g)" -v "$D/out/probes-$N/vocoded:/in:ro" -v "$R/samples:/out" \ --entrypoint python tiny-voca-dk:v4 -c " import glob, os, numpy as np, soundfile as sf for f in sorted(glob.glob('/in/*.wav')): w, sr = sf.read(f, dtype='float32') sf.write('/out/' + os.path.basename(f), w * min(1.0, 0.99 / max(float(np.abs(w).max()), 1e-9)), sr, subtype='PCM_16') " # showcase clips for the card's players: release/hf/showcase.jsonl read by speak.py with the int8 # ONNX model, exactly as a user would run it (checked with Whisper on 2026-11-27: all read right) cp "$S/release/hf/showcase.jsonl" "$R/samples/showcase.jsonl" docker run --rm --user "$(id -u):$(id -g)" -v "$R:/release" --entrypoint python tiny-voca-dk:v4 -c " import json, subprocess, sys for line in open('/release/samples/showcase.jsonl', encoding='utf-8'): if line.strip(): r = json.loads(line) subprocess.run([sys.executable, '/release/speak.py', r['text'], '--model', '/release/onnx/model-int8.onnx', '--output', '/release/samples/' + r['id'] + '.wav'], check=True, stdout=subprocess.DEVNULL) " 2>&1 | grep -v -i "warn" || true ls "$R"/samples/showcase_*.wav | wc -l # evaluation reports (this model, the equal-steps control on the old frontend, the recordings) for f in asr/$N quality/$N asr/tex1k220k-vocCT3bsm9 quality/tex1k220k-vocCT3bsm9 asr/whisper-baseline; do [[ -f "$D/checks/$f.json" ]] && cp "$D/checks/$f.json" "$R/eval/$(echo "$f" | tr / _).json" done cp "$D/checks/g2p-nst-v1-ar-eval.json" "$R/eval/g2p_nst_v1_eval.json" for o in onnx-$N onnx-int8-$N; do cp "$D/out/$o/onnx_check.json" "$R/eval/$o-check.json"; done # training recipe: Dockerfiles, compose, scripts, kits (local paths and host names scrubbed) cp -r "$S/docker" "$S/scripts" "$S/kit-v3" "$S/compose.yaml" "$R/recipe/" mkdir -p "$R/recipe/kit-v4/resources"; cp -r "$S/kit-v4/patches" "$R/recipe/kit-v4/" echo "Copy ../../frontend/{da_g2p_nst_v1.pt,da_g2p_nst_v1.symbols.json,danish_g2p_data.py} here before building docker/Dockerfile.v4." \ > "$R/recipe/kit-v4/resources/README.txt" find "$R/recipe" -name __pycache__ -prune -exec rm -rf {} + grep -rIl -e "$HOME" -e '192\.168\.' -e "$(id -un)" "$R" | while read -r f; do sed -i -e "s#$HOME/models/tiny-voca-dk#/srv/tiny-voca-dk#g" -e "s#$HOME#\$HOME#g" \ -e 's#192\.168\.[0-9]*\.[0-9]*#gpu-host#g' -e "s#$(id -un)#user#g" "$f" done if grep -rIl -e "$(id -un)" -e '192\.168\.' "$R"; then echo "personal strings left" >&2; exit 1; fi ( cd "$R" && find . -type f ! -name SHA256SUMS -print0 | sort -z | xargs -0 sha256sum > SHA256SUMS ) du -sh "$R"; find "$R" -maxdepth 2 -type f -size +1M -exec ls -la {} \;