Evaluation scripts for the Open TTS Leaderboard: https://huggingface.co/spaces/hf-audio/open_tts_leaderboard
Python
Add VieNeu-TTS v3 Turbo evaluation backend (#34)
zohuyhieuzo0397109c086cf9
diff --git a/vieneu/run_eval.py b/vieneu/run_eval.pynew file mode 100644index 0000000..561045f--- /dev/null+++ b/vieneu/run_eval.py@@ -0,0 +1,104 @@+"""+TTS synthesis for the Open TTS Leaderboard (VieNeu-TTS v3 Turbo backend, stage 1).++VieNeu-TTS v3 Turbo (pnnbao-ump/VieNeu-TTS-v3-Turbo, Apache-2.0) is a Vietnamese/English TTS model+(48 kHz) driven through the `vieneu` Python SDK (https://github.com/pnnbao97/VieNeu-TTS). On a CUDA+machine the SDK uses its PyTorch engine and batches the text chunks of many inputs into one forward+pass (`infer_batch`). Default preset voice, no voice cloning, so no stage 3 (SIM).++Per-sample generation time is the minibatch time divided by the minibatch size, as in the other+batched backends. `--batch_size` is also the manifest-writing / resume granularity.+"""++import argparse+import os+import time+from importlib.metadata import version++import numpy as np+import soundfile as sf+import torch+from tqdm import tqdm++from vieneu import Vieneu++from run_eval_utils import (+ add_common_args, load_done_entries, load_tts_dataset, manifest_entry, open_manifest, output_paths,+ pending_batches, print_model_size, print_next_steps, set_seed, warm_up, wav_rel_path, write_entry,+)+++def main(args):+ set_seed(args.seed)++ device = "cuda" if args.device.startswith("cuda") else "cpu"+ tts = Vieneu(device=device)+ print(f"Loaded VieNeu-TTS v3 Turbo (vieneu {version('vieneu')}, device={device}, "+ f"sample_rate={tts.sample_rate}, voice={args.voice or 'default'})")+ print_model_size(getattr(tts, "model", None))++ sampling_rate = int(tts.sample_rate)+ is_cuda = device == "cuda"++ def synth_batch(texts):+ """Synthesize a list of texts. Return (list of 1d float32 arrays, elapsed_s)."""+ if is_cuda:+ torch.cuda.synchronize()+ start = time.perf_counter()+ wavs = tts.infer_batch(texts, voice=args.voice)+ if is_cuda:+ torch.cuda.synchronize()+ elapsed = time.perf_counter() - start+ out = []+ for w in wavs:+ w = np.asarray(w, dtype=np.float32).reshape(-1)+ out.append(w if w.size else np.zeros(1, dtype=np.float32))+ return out, elapsed++ paths = output_paths(args)+ model_dir, dataset_dir_name, manifest_path = paths.model_dir, paths.dataset_dir_name, paths.manifest_path++ dataset = load_tts_dataset(args)++ if args.ttfa_probe != 0:+ raise SystemExit("--ttfa_probe is not implemented for this backend.")++ done_entries = load_done_entries(manifest_path, args.resume)+ manifest_file = open_manifest(manifest_path, done_entries)++ starts = pending_batches(dataset, args.batch_size, done_entries, dataset_dir_name)+ warm_up(lambda batch: synth_batch(list(batch[args.text_column])), dataset, starts, args.batch_size, args.warmup_steps)+ set_seed(args.seed) # warm-up must not shift the RNG stream of the timed run++ for start in tqdm(starts, desc="Generating"):+ batch = dataset[start : start + args.batch_size]+ texts = list(batch[args.text_column])+ wavs, elapsed = synth_batch(texts)+ per_sample = elapsed / len(texts)+ for sample_id, text, audio in zip(batch["id"], texts, wavs):+ rel_path = wav_rel_path(dataset_dir_name, sample_id)+ sf.write(os.path.join(model_dir, rel_path), audio, sampling_rate)+ write_entry(manifest_file, manifest_entry(rel_path, len(audio) / sampling_rate, per_sample, text))+ manifest_file.flush()++ manifest_file.close()+ 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="pnnbao-ump/VieNeu-TTS-v3-Turbo",+ help="Model repo id (recorded in the manifest folder name; weights are fetched by the SDK).")+ parser.add_argument("--voice", type=str, default=None,+ help="Preset voice name or id (default: the SDK's default preset voice).")+ add_common_args(parser, batch_size=32)+ parser.set_defaults(split="vi")++ args = parser.parse_args()++ print("*" * 100)+ print(f"Generating TTS with {args.model_id} on {args.dataset_path} / {args.dataset} / {args.split}")+ print("*" * 100)++ main(args)diff --git a/vieneu/submit_jobs.sh b/vieneu/submit_jobs.shnew file mode 100755index 0000000..29d02ed--- /dev/null+++ b/vieneu/submit_jobs.sh@@ -0,0 +1,48 @@+#!/bin/bash+# HF Jobs TTS eval — VieNeu-TTS v3 Turbo backend (fixed default voice → generate → transcribe → score; no SIM).+# Runs locally; submits HF Jobs. Usage: HF_TOKEN=hf_... bash submit_jobs.sh ["pnnbao-ump/VieNeu-TTS-v3-Turbo" ...]+# 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-vieneu}" # stage-1 image (Dockerfile in the Space: https://huggingface.co/spaces/bezzam/evals-vieneu/blob/main/Dockerfile)+# gen FLAVOR (h200) is set centrally in tts_jobs_common.sh for RTFx comparability — don't override.+DEFAULT_STAGES="generate transcribe" # no SIM (default voice); no UTMOS (English only)+RUN_EVAL_INJECT="$(inject_run_eval)"++# Vietnamese only for now (the model is Vietnamese/English).+supports_language() { [[ "$1" == "vi" ]]; }++# ── Stage 1: TTS generation (batched on GPU) ─────────────────────────────────+generate_stage() {+ local _ BATCH_SIZE+ read -r _ BATCH_SIZE <<< "${MODEL_CFG}"+ hf jobs run \+ --flavor "${FLAVOR}" --timeout "${GEN_TIMEOUT:-8h}" --secrets HF_TOKEN ${NAMESPACE_ARG} \+ --volume "hf://buckets/${RESULTS_BUCKET}:/results" "${TTS_IMAGE}" \+ bash -c "+ ${RUN_EVAL_INJECT}+ cd /app/vieneu && python run_eval.py \+ --model_id=${MODEL_ID} \+ --batch_size=${BATCH_SIZE:-32} \+ --dataset_path=${DATASET_PATH} \+ --dataset=${DATASET} \+ --split=${SPLIT} \+ --device=cuda:0 \+ --max_eval_samples=${MAX_EVAL_SAMPLES} &&+ mkdir -p /results &&+ cp -r results/${MODEL_SAFE} /results/+ "+}++# ── Datasets: "config split asr_language [dataset_path]" ─────────────────────+# MiniMax multilingual: 100 sentences per language, public at hf-audio/minimax_eval.+DATASET_CONFIGS=(+ "tts vi vi ${MINIMAX_EVAL_PATH}"+)++# ── Models: "model_id batch_size" (CLI args override) ────────────────────────+MODEL_CONFIGS=("pnnbao-ump/VieNeu-TTS-v3-Turbo 32")+[[ $# -gt 0 ]] && MODEL_CONFIGS=("$@")++run_pipeline