#!/bin/bash
# Download the Higgs TTS 3 checkpoint from HuggingFace.
# Usage: ./checkpoints.sh
# The single repo bundles the Qwen3-4B talker and the audio codec
# (encoder, RVQ quantizer, DAC decoder, semantic model) in one
# model.safetensors.

set -eu

DIR="checkpoints"
mkdir -p "$DIR"

HF="hf download --quiet"

dl_repo() {
    local name="$1" repo="$2"
    local target="$DIR/$name"
    if [ -d "$target" ] && [ "$(ls "$target"/*.safetensors 2>/dev/null | wc -l)" -gt 0 ]; then
        echo "[OK] $name"
        return
    fi
    echo "[Download] $name <- $repo"
    $HF "$repo" --local-dir "$target"
}

dl_repo "higgs-tts-3-4b" "bosonai/higgs-tts-3-4b"
