r"""One system, one GPU: render every benchmark prompt, then transcribe with both judges. Run by the m3_bench kernels as ``python worker.py spec.json`` with CUDA_VISIBLE_DEVICES set to one card, and with no Hugging Face token in the environment: everything it loads was downloaded by the parent and is passed as a local folder. Each system is run the way its own card says, single shot, one fixed seed per prompt (``seed + 100 * index``, the same for every system): geetha release\inference.py exactly as shipped: speak(text, speaker, retries=0), neutral style, no breath tag. base bodhan-ai/indic-speak through its own inference.py: tts(text, speaker="Anitha"|"Arun"), temperature 0.6, top-p 0.9, top-k 50 (its defaults), same 22 s cap as Geetha. rumik_oss_1 rumik-ai/rumik-oss-1, voice Ira, temperature 0.8, top-k 30. snortts_indic_v0 snorbyte/snorTTS-Indic-v0, speaker tamil188, temperature 0.4, top-p 0.9, repetition penalty 1.05, stock SNAC decoder. A clip that is mute or never ended is invalid: its own rate, never sent to a judge. A prompt the time budget did not reach is "not_run", which is neither. The result file is rewritten after every clip, so a kernel that dies still leaves what it made. """ from __future__ import annotations import json import sys import time import traceback import warnings from pathlib import Path import numpy as np SAMPLE_RATE, JUDGE_RATE = 24_000, 16_000 CAP_SECONDS = 22.0 TOKENS_PER_SECOND = 82 RUMIK = dict(speaker="Ira", temperature=0.8, top_k=30, max_new_tokens=2048) SNOR = dict(speaker="tamil188", temperature=0.4, top_p=0.9, repetition_penalty=1.05, max_new_tokens=int(CAP_SECONDS * TOKENS_PER_SECOND)) BASE = dict(temperature=0.6, top_p=0.9, top_k=50, max_new_tokens=int(CAP_SECONDS * TOKENS_PER_SECOND)) def main() -> int: spec = json.loads(Path(sys.argv[1]).read_text(encoding="utf-8")) system: str = spec["system"] prompts: list[dict] = spec["prompts"] out_dir = Path(spec["out_dir"]) audio = out_dir / "clips" audio.mkdir(parents=True, exist_ok=True) result_path = out_dir / f"bench_{system}.json" started = time.time() render_deadline = started + float(spec["render_budget_s"]) def log(message: str) -> None: print(f"[{system}] {message}", flush=True) import soundfile as sf import torch import torchaudio sys.path.insert(0, spec["package_parent"]) from geetha.eval.validity import check_clip half = torch.cuda.get_device_capability(0)[0] < 8 dtype = torch.float16 if half else torch.bfloat16 log(f"gpu: {torch.cuda.get_device_name(0)} half precision: {half} " f"{len(prompts)} prompts") rows: dict[str, dict] = {} hyps: dict[str, dict[str, str]] = {} report = {"system": system, "seed": spec["seed"], "seed_rule": "seed + 100 * index", "single_shot": True, "cap_seconds": CAP_SECONDS, "half_precision": half, "decoding": {"geetha": "release/inference.py defaults (CONV: temperature 0.6, " "top-p 0.9, top-k 50, no guidance), retries=0", "base": BASE, "rumik_oss_1": RUMIK, "snortts_indic_v0": SNOR}[system], "revisions": spec.get("revisions", {}), "failure": None, "clips": rows, "hypotheses": hyps} def flush() -> None: report["elapsed_s"] = round(time.time() - started) result_path.write_text(json.dumps(report, ensure_ascii=False, indent=1), encoding="utf-8") # ------------------------------------------------------------------ renderers def load_geetha(): sys.path.insert(0, spec["release_dir"]) import inference # the shipped file, as the README says tts = inference.Geetha(spec["adapter_dir"], base=spec["base_dir"], device="cuda") def render(text: str, voice: str, seed: int): with warnings.catch_warnings(record=True) as caught: warnings.simplefilter("always") wav = tts.speak(text, speaker=voice, seed=seed, retries=0) stuck = any("stayed invalid" in str(w.message) for w in caught) # speak() folds "silent" and "never ended" into one warning; the level check # below separates them, so only a loud clip with the warning is a cap hit. return wav, not stuck or not check_clip(wav, SAMPLE_RATE).valid return render def load_base(): import importlib.util sys.path.insert(0, spec["base_dir"]) module_spec = importlib.util.spec_from_file_location( "indic_speak_inference", str(Path(spec["base_dir"]) / "inference.py")) loader = importlib.util.module_from_spec(module_spec) sys.modules[module_spec.name] = loader module_spec.loader.exec_module(loader) tts = loader.TTS(spec["base_dir"], device="cuda") if half: tts.lm = tts.lm.half() # the same cast the Geetha release makes def render(text: str, voice: str, seed: int): with warnings.catch_warnings(record=True) as caught: warnings.simplefilter("always") wav = tts(text, speaker=voice.capitalize(), seed=seed, **BASE) capped = any("hit max_new_tokens" in str(w.message) for w in caught) return wav, not capped return render def load_rumik(): from transformers import AutoModelForCausalLM, AutoTokenizer, MimiModel folder = spec["rumik_dir"] tok = AutoTokenizer.from_pretrained(folder) lm = AutoModelForCausalLM.from_pretrained( folder, trust_remote_code=True, dtype=dtype).eval().cuda() mimi = MimiModel.from_pretrained(folder, subfolder="codec").eval().cuda() def render(text: str, voice: str, seed: int): torch.manual_seed(seed) inputs = tok(f'{RUMIK["speaker"]}: {text}