Skip to content

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

Python

Add tiny voca (#56)

Eric Bezzam2e35df74c115
diff --git a/submit_ttfa_jobs.sh b/submit_ttfa_jobs.sh
index ad442f3..8b53c6f 100755
--- a/submit_ttfa_jobs.sh
+++ b/submit_ttfa_jobs.sh
@@ -241,6 +241,11 @@ TTFA_TARGETS=(
"sanotts-heart|sanotts||ampixa/sanoTTS|--voice=heart --threads=1"
"sanotts-amy|sanotts||ampixa/sanoTTS|--voice=amy --threads=1"
"sanotts-heart-nano|sanotts||ampixa/sanoTTS|--voice=heart-nano --threads=1"
+ # CPU only (run_eval.py refuses a GPU device): TTFA_DEVICE=cpu bash submit_ttfa_jobs.sh tiny-voca-f2
+ # No Space: python:3.12-slim + pip install from tiny-voca/job_image.sh. One target per voice;
+ # whole-utterance synthesis (no streaming API); --threads=1 as in the eval.
+ "tiny-voca-f2|tiny-voca||n4ze3m/tiny-voca|--voice=F2 --threads=1"
+ "tiny-voca-m2|tiny-voca||n4ze3m/tiny-voca|--voice=M2 --threads=1"
# HTTP CLIENTS of an inference server the job starts itself (see the preamble in submit_one);
# --server_pid makes a dead server fail the wait immediately.
"voxtral-tts|voxtral-tts|bezzam/evals-voxtral|mistralai/Voxtral-4B-TTS-2603|--base_url=http://localhost:${VLLM_PORT} --server_pid=\${SERVER_PID}"
@@ -274,6 +279,7 @@ NO_CLONE_FLAG=(
scyllasband
sanotts
supertonic
+ tiny-voca
vibevoice_realtime
voxtral-tts
woof
diff --git a/tiny-voca/job_image.sh b/tiny-voca/job_image.sh
new file mode 100644
index 0000000..868b9c3
--- /dev/null
+++ b/tiny-voca/job_image.sh
@@ -0,0 +1,30 @@
+# Stage-1 environment for the tiny-voca backend, sourced by tiny-voca/submit_jobs.sh (eval) and
+# submit_ttfa_jobs.sh (TTFA probe), so both measure the same install. Defines GEN_IMAGE and
+# gen_setup.
+#
+# No Docker Space needed. tiny-voca is a 4.5 M PyTorch model that runs on CPU (apache-2.0), so the
+# job uses the public slim Python image and pip-installs the pinned packages at job start (~15 s).
+# The weights come from the model repo at the pinned revision set in run_eval.py.
+GEN_IMAGE="${GEN_IMAGE:-python:3.12-slim}"
+
+# tiny-voca ships as a GitHub-only Python package; same for its phonemizer (dizione). Both pinned
+# to their 2026-11-16 main HEADs. Torch is the CPU wheel from PyTorch's /whl/cpu index.
+TINY_VOCA_REV="${TINY_VOCA_REV:-main}"
+DIZIONE_REV="${DIZIONE_REV:-main}"
+
+# gen_setup <device> → `... &&` install snippet for the job body. CPU only: the device is not used.
+# python:3.12-slim ships without git or espeak-ng; the job apt-installs both. dizione and tiny-voca
+# are GitHub-only (no PyPI release yet), and dizione falls back to the espeak-ng CLI for words its
+# built-in lexicon doesn't cover ("Install espeak-ng on the cloud machine..." otherwise). Then torch
+# from the CPU wheel index (so +cpu is resolvable), and the rest from PyPI (so --index-url doesn't
+# apply to packages that only live there).
+gen_setup() {
+ cat <<INSTALL
+apt-get update -qq && apt-get install -y --no-install-recommends git espeak-ng >/dev/null &&
+pip install --no-cache-dir -q --index-url https://download.pytorch.org/whl/cpu torch==2.8.0+cpu &&
+pip install --no-cache-dir -q \
+ numpy==2.4.2 soundfile==0.13.1 datasets==3.6.0 tqdm==4.70.1 huggingface_hub==0.36.2 \
+ git+https://github.com/n4ze3m/dizione@${DIZIONE_REV} \
+ git+https://github.com/n4ze3m/tiny-voca@${TINY_VOCA_REV} &&
+INSTALL
+}
diff --git a/tiny-voca/run_eval.py b/tiny-voca/run_eval.py
new file mode 100644
index 0000000..f9c02e6
--- /dev/null
+++ b/tiny-voca/run_eval.py
@@ -0,0 +1,174 @@
+"""
+TTS synthesis for the Open TTS Leaderboard (tiny-voca backend, stage 1).
+
+tiny-voca (https://huggingface.co/n4ze3m/tiny-voca, code
+https://github.com/n4ze3m/tiny-voca) is a 4,537,291-parameter English TTS trained from scratch at
+24 kHz with two voices (F2 and M2). Its waveform generator is a source-filter synthesizer (no
+neural vocoder) so the whole model is one small torch graph. CPU-only (the model card reports
+~70x real-time on four CPU threads).
+
+Each voice is evaluated as its own leaderboard row:
+ * ``F2`` default row (no manifest suffix).
+ * ``M2`` variant row, manifest suffix ``_m2`` (publish with ``--variant m2``).
+
+Weights come from ``n4ze3m/tiny-voca``'s ``tiny-voca.pt`` at a pinned revision. The phonemizer
+is ``dizione`` (https://github.com/n4ze3m/dizione), whose data files live in the same repo under
+``phonemizer/``; this script points it at the downloaded copy via the ``DIZIONE_DATA`` env var
+before importing ``tiny_voca.infer``.
+
+Text handling is exactly what ``tiny_voca.infer.speak_text`` does: sentence split (abbreviation-
+and initial-aware), an added full stop if the text has no closing mark, each sentence synthesized
+as one call of the model, long sentences cut at commas then between words, and the audio joined
+peak-limited to 0.99. A text with nothing to pronounce (another script, signs only) is left as
+one tenth of a second of silence.
+
+Device: CPU only. ``--threads`` caps torch intra-op threads (default 1: a fixed count keeps RTFx
+independent of the host's core count, matching the sanotts convention).
+"""
+
+import argparse
+import os
+import time
+
+import numpy as np
+import soundfile as sf
+import torch
+from tqdm import tqdm
+
+from run_eval_utils import (
+ add_common_args, load_done_entries, load_tts_dataset, manifest_entry, open_manifest, output_paths,
+ pending_batches, print_next_steps, warm_up, wav_rel_path, write_entry,
+)
+
+SAMPLE_RATE = 24000
+
+# Pinned model repo revision (n4ze3m/tiny-voca main on 2026-11-16).
+MODEL_REVISION = "eac048b7a4392584725af9792460a0211fa1cac7"
+
+VOICES = {
+ "F2": "", # default row
+ "M2": "_m2", # variant row (publish with --variant m2)
+}
+DEFAULT_VOICE = "F2"
+
+
+def main(args):
+ if not args.device.startswith("cpu"):
+ raise SystemExit("tiny-voca runs on CPU only; pass --device=cpu.")
+ torch.set_num_threads(args.threads)
+ torch.set_num_interop_threads(1)
+
+ from huggingface_hub import snapshot_download
+ if args.checkpoint_path:
+ repo_dir = args.checkpoint_path
+ else:
+ repo_dir = snapshot_download(
+ args.model_id, revision=args.revision,
+ local_dir=os.path.join(args.local_dir, args.model_id.replace("/", "-")),
+ allow_patterns=["tiny-voca.pt", "config.json", "phonemizer/**"],
+ )
+ print(f"Checkpoint: {repo_dir} (revision {args.revision})")
+
+ # dizione reads its lexicon/G2P tables from this folder. Must be set BEFORE importing tiny_voca.
+ os.environ["DIZIONE_DATA"] = os.path.join(repo_dir, "phonemizer")
+ from tiny_voca.infer import load_model, speak_text # noqa: E402
+
+ if args.voice not in VOICES:
+ raise SystemExit(f"--voice must be one of {list(VOICES)}")
+
+ # ``check_frontend=False`` accepts the dizione/tiny-voca fingerprint mismatch introduced by
+ # dizione's post-release code tweaks (Nov 15 — see ``dizione.identity``). The author documents
+ # this flag as the intended way to run a checkpoint against the new phonemizer; the phoneme
+ # inventory is unchanged, so per-sample WER drift versus the card's panel is small.
+ model = load_model(os.path.join(repo_dir, "tiny-voca.pt"), device="cpu", check_frontend=False)
+ n_params = sum(p.numel() for p in model.parameters())
+ print(f"Loaded tiny-voca voice={args.voice} | {n_params / 1e9:.4f}B parameters ({n_params:,}).")
+
+ failures = []
+
+ def synth_one(text):
+ """Return (audio float32, elapsed_s). A text with nothing pronounceable or one word that
+ exceeds the frame budget is scored as silence."""
+ start = time.perf_counter()
+ try:
+ with torch.inference_mode():
+ wave, _ = speak_text(model, text, args.voice, seed=args.seed)
+ audio = wave.detach().cpu().float().numpy().astype(np.float32, copy=False)
+ except (ValueError, RuntimeError) as exc:
+ failures.append(str(exc))
+ print(f"WARNING: refused ({exc}); writing silence for: {text[:80]!r}")
+ audio = np.zeros(SAMPLE_RATE // 10, dtype=np.float32)
+ return audio, time.perf_counter() - start
+
+ # ``MODE_SUFFIX`` picks the per-voice manifest name — the orchestrator's _wait_and_score looks for
+ # ``..._<split><MODE_SUFFIX>.jsonl`` in the bucket (see scripts/tts_jobs_common.sh).
+ mode_suffix = VOICES[args.voice]
+ paths = output_paths(args, mode_suffix)
+ model_dir, dataset_dir_name, manifest_path = paths.model_dir, paths.dataset_dir_name, paths.manifest_path
+
+ dataset = load_tts_dataset(args)
+
+ # ── TTFA probe: latency only, writing nothing but a JSON sidecar ─────────
+ # No streaming API, so `first` is None and the probe records the whole-utterance time.
+ if args.ttfa_probe != 0:
+ from ttfa_probe import run_probe, sample_indices
+ run_probe(
+ lambda job: (synth_one(job["text"])[0], SAMPLE_RATE, None),
+ [{"text": dataset[i][args.text_column]} for i in sample_indices(args.ttfa_probe, len(dataset))],
+ model_id=args.model_id, dataset_path=args.dataset_path,
+ dataset_config=args.dataset, split=args.split,
+ out_dir=model_dir, mode_suffix=mode_suffix, n=args.ttfa_probe,
+ extra={"device": args.device, "voice": args.voice, "seed": args.seed,
+ "threads": args.threads, "revision": args.revision},
+ )
+ return
+
+ done_entries = load_done_entries(manifest_path, args.resume)
+ manifest_file = open_manifest(manifest_path, done_entries)
+
+ starts = pending_batches(dataset, 1, done_entries, dataset_dir_name)
+ warm_up(lambda batch: [synth_one(t) for t in batch[args.text_column]], dataset, starts, 1, args.warmup_steps)
+ failures.clear()
+
+ for i in tqdm(starts, desc="Generating"):
+ sample_id = dataset[i]["id"]
+ text = dataset[i][args.text_column]
+ rel_path = wav_rel_path(dataset_dir_name, sample_id)
+ audio, elapsed = synth_one(text)
+ sf.write(os.path.join(model_dir, rel_path), audio, SAMPLE_RATE)
+ write_entry(manifest_file, manifest_entry(rel_path, len(audio) / SAMPLE_RATE, elapsed, text))
+ manifest_file.flush()
+
+ manifest_file.close()
+ print(f"Refused texts (scored as silence): {len(failures)} of {len(starts)}")
+ print("Results saved at path:", os.path.abspath(manifest_path))
+ print_next_steps(voice_clone=False)
+
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser()
+ parser.add_argument("--model_id", type=str, default="n4ze3m/tiny-voca",
+ help="tiny-voca model repo (apache-2.0).")
+ parser.add_argument("--revision", type=str, default=MODEL_REVISION,
+ help="Model repo revision (default: main on 2026-11-16).")
+ parser.add_argument("--checkpoint_path", type=str, default=None,
+ help="Local copy of the repo. Default: download --model_id under --local_dir.")
+ parser.add_argument("--local_dir", type=str, default="/tmp/tiny_voca_models",
+ help="Where to materialise the model repo as real files.")
+ parser.add_argument("--voice", type=str, default=DEFAULT_VOICE,
+ help=f"One of {list(VOICES)}. {DEFAULT_VOICE} is the default row.")
+ parser.add_argument("--threads", type=int, default=1,
+ help="torch intra-op threads (default 1 for RTFx independent of host cores).")
+ add_common_args(parser)
+ # ``--device`` comes from ``add_common_args``; override the default to cpu since tiny-voca is
+ # CPU-only (``main`` refuses a GPU device).
+ parser.set_defaults(seed=0, device="cpu")
+
+ args = parser.parse_args()
+
+ print("*" * 100)
+ print(f"Generating TTS with {args.model_id} voice={args.voice} on "
+ f"{args.dataset_path} / {args.dataset} / {args.split}")
+ print("*" * 100)
+
+ main(args)
diff --git a/tiny-voca/submit_jobs.sh b/tiny-voca/submit_jobs.sh
new file mode 100755
index 0000000..1546c68
--- /dev/null
+++ b/tiny-voca/submit_jobs.sh
@@ -0,0 +1,77 @@
+#!/bin/bash
+# HF Jobs TTS eval — tiny-voca backend (fixed voice → generate → transcribe → UTMOS → score; no SIM).
+# Runs locally; submits HF Jobs. Usage: HF_TOKEN=hf_... bash tiny-voca/submit_jobs.sh ["n4ze3m/tiny-voca F2" ...]
+# Smoke test: MAX_EVAL_SAMPLES=8 bash tiny-voca/submit_jobs.sh
+# 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 ───────────────────────────────────────────────────────────
+# Stage-1 environment: no Docker Space. GEN_IMAGE and gen_setup live in job_image.sh; shared with
+# submit_ttfa_jobs.sh so the TTFA probe runs the same install.
+source "${BACKEND_DIR}/job_image.sh"
+# torch intra-op threads (run_eval.py's --threads). 1: tiny-voca's matrices are small, and a fixed
+# count keeps RTFx independent of the h200 host's core count. The TTFA targets pass the same value.
+TINY_VOCA_THREADS="${TINY_VOCA_THREADS:-1}"
+GEN_TIMEOUT="${GEN_TIMEOUT:-2h}"
+# gen FLAVOR (h200) is set centrally in tts_jobs_common.sh for RTFx comparability — don't override.
+DEFAULT_STAGES="generate transcribe utmos" # no SIM (fixed voice)
+RUN_EVAL_INJECT="$(inject_run_eval)"
+
+# ── Voice → output suffix ────────────────────────────────────────────────────
+# Both voices share one repo, so a non-default voice is a leaderboard variant: MODE_SUFFIX must match
+# the suffix run_eval.py writes (publish with `open_results_pr.py --variant m2`).
+resolve_mode() {
+ local _ VOICE
+ read -r _ VOICE <<< "${MODEL_CFG}"
+ CLONE="false"; VOICE_CLONE_FLAG=""
+ case "${VOICE:-F2}" in
+ F2) MODE_SUFFIX="" ;;
+ M2) MODE_SUFFIX="_m2" ;;
+ *) echo "tiny-voca: unknown voice '${VOICE}' (F2, M2)" >&2; exit 1 ;;
+ esac
+ true
+}
+
+# English only (American English phonemizer).
+supports_language() { [[ "$1" == "en" ]]; }
+
+# ── Stage 1: TTS generation ─────────────────────────────────────────────────
+# CPU on the host CPU of the h200 flavor; --device=cpu is enforced inside run_eval.py.
+generate_stage() {
+ local _ VOICE
+ read -r _ VOICE <<< "${MODEL_CFG}"
+ hf jobs run \
+ --flavor "${FLAVOR}" --timeout "${GEN_TIMEOUT}" --secrets HF_TOKEN ${NAMESPACE_ARG} \
+ --volume "hf://buckets/${RESULTS_BUCKET}:/results" "${GEN_IMAGE}" \
+ bash -c "
+ ${RUN_EVAL_INJECT}
+ $(gen_setup cpu)
+ cd /app/tiny-voca && python run_eval.py \
+ --model_id=${MODEL_ID} \
+ --voice=${VOICE:-F2} \
+ --dataset_path=${DATASET_PATH} \
+ --dataset=${DATASET} \
+ --split=${SPLIT} \
+ --device=cpu \
+ --threads=${TINY_VOCA_THREADS} \
+ --max_eval_samples=${MAX_EVAL_SAMPLES} &&
+ mkdir -p /results &&
+ cp -r results/${MODEL_SAFE} /results/
+ "
+}
+
+# ── Datasets: "config split asr_language [dataset_path]" ────────────────────
+DATASET_CONFIGS=(
+ "tts en en"
+ "zero_shot en en ${CV3_EVAL_PATH:-hf-audio/cv3_eval}"
+ "tts en en ${MINIMAX_EVAL_PATH}"
+)
+
+# ── Models: "model_id voice" (CLI args override) ────────────────────────────
+MODEL_CONFIGS=(
+ "n4ze3m/tiny-voca F2"
+ "n4ze3m/tiny-voca M2"
+)
+[[ $# -gt 0 ]] && MODEL_CONFIGS=("$@")
+
+run_pipeline