Skip to content

Evaluation scripts for the Open TTS Leaderboard: https://huggingface.co/spaces/hf-audio/open_tts_leaderboard

Python
2.5 KB
Raw Blame
#!/bin/bash
# HF Jobs TTS eval — OmniVoice backend (generate → transcribe → SIM* → score; *voice-clone only).
# Runs locally; submits HF Jobs. Usage: HF_TOKEN=hf_... bash submit_jobs.sh ["k2-fsa/OmniVoice 32" ...]
# Shared orchestration (stages 2/3, injection, logging, scoring) lives in scripts/tts_jobs_common.sh.
source "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/scripts/tts_jobs_common.sh"

# ── Backend config ───────────────────────────────────────────────────────────
TTS_SPACE="${TTS_SPACE:-bezzam/evals-omnivoice}"   # stage-1 image (Dockerfile in the Space: https://huggingface.co/spaces/bezzam/evals-omnivoice/blob/main/Dockerfile)
# gen FLAVOR (h200) is set centrally in tts_jobs_common.sh for RTFx comparability — don't override.
RUN_EVAL_INJECT="$(inject_run_eval)"

# VOICE_CLONE=true: zero-shot voice cloning + SIM; false (default) = auto-voice.
SUPPORTS_VOICE_CLONE=true

# Vietnamese fine-tunes of OmniVoice (same architecture and loader): score them on Vietnamese only.
VI_FINETUNES=" kjanh/KhanhTTS-OmniVoice splendor1811/omnivoice-vietnamese "
supports_language() { [[ "${VI_FINETUNES}" != *" ${MODEL_ID} "* || "$1" == "vi" ]]; }

# ── Stage 1: TTS generation. MODEL_CFG = "model_id batch_size". ──
generate_stage() {
    local _ BATCH_SIZE
    read -r _ BATCH_SIZE <<< "${MODEL_CFG}"
    hf jobs run \
        --flavor "${FLAVOR}" --timeout 8h --secrets HF_TOKEN ${NAMESPACE_ARG} \
        --volume "hf://buckets/${RESULTS_BUCKET}:/results" "${TTS_IMAGE}" \
        bash -c "
            ${RUN_EVAL_INJECT}
            cd /app/omnivoice && python run_eval.py \
                --model_id=${MODEL_ID} \
                --dataset_path=${DATASET_PATH} \
                --dataset=${DATASET} \
                --split=${SPLIT} \
                --language=${ASR_LANG} \
                --device=cuda:0 \
                --batch_size=${BATCH_SIZE} \
                --max_eval_samples=${MAX_EVAL_SAMPLES} \
                ${VOICE_CLONE_FLAG} &&
            mkdir -p /results &&
            cp -r results/${MODEL_SAFE} /results/
        "
}

# ── Models: "model_id batch_size" (CLI args override) ────────────────────────
MODEL_CONFIGS=(
    "k2-fsa/OmniVoice 32"
    "kjanh/KhanhTTS-OmniVoice 32"
    "splendor1811/omnivoice-vietnamese 32"
)
[[ $# -gt 0 ]] && MODEL_CONFIGS=("$@")

run_pipeline