""" Data layer for the Open TTS Leaderboard. Loads the evaluation results from the `hf-audio/tts_leaderboard_results` dataset and exposes them as plain Python structures the Gradio app can slice by language / dataset / voice-cloning mode. Files in the dataset repo ------------------------- | source key | file | contents | |--------------------|----------------------------|----------------------------| | `model_info` | `model_info.csv` | per-model metadata | | `seed_tts` | `seed_tts.csv` | Seed-TTS, no cloning | | `seed_tts_clone` | `seed_tts_voice_clone.csv` | Seed-TTS, voice cloning | | `cv3` | `cv3.csv` | CV3-Eval, no cloning | | `cv3_clone` | `cv3_voice_clone.csv` | CV3-Eval, voice cloning | | `minimax` | `minimax.csv` | MiniMax, no cloning | | `minimax_clone` | `minimax_voice_clone.csv` | MiniMax, voice cloning | | `neyshekar` | `neyshekar.csv` | Neyshekar, no cloning | | `neyshekar_clone` | `neyshekar_voice_clone.csv`| Neyshekar, voice cloning | | `ztts2_clean` | `ztts2_mini_clean.csv` | ZTTS2 clean, no cloning | | `ztts2_clean_clone`| `ztts2_mini_clean_voice_clone.csv` | ZTTS2 clean, cloning | Which commit of each file is read comes from `VERSIONS` (see below), so a past snapshot of the leaderboard can be reproduced by pinning revisions. Every results file is "wide": one row per model, and per-language column groups named `" WER"`, `" RTFx"`, `" UTMOS"`, `" KOMOS"` and (cloning only) `" SIM"`. `` is almost always a 2-letter ISO 639-1 code, but MiniMax's Cantonese split is the 3-letter `"yue"` — ignoring `avg *` columns is handled explicitly alongside that (see `_METRIC_RE`) since widening the code length would otherwise also match `"avg WER"` et al. as a fake language. Pre-computed `avg *` columns are ignored regardless — averages are always recomputed here from the languages/datasets the user has selected, so the number in the table always matches the current selection. Note on SIM: the cloning files may also carry a legacy `" SIM (microsoft/wavlm-base-plus-sv)"` column. That is a *different* speaker-similarity scale (x-vector) and is deliberately not read — only the canonical seed-tts-eval WavLM scale (`" SIM"`) is used. Note on UTMOS: only ever populated for `"en"` — UTMOS22, the MOS-prediction model behind it, was trained on English speech only (https://github.com/sarulab-speech/UTMOS22). ``aggregate_rows`` surfaces it as a headline, English-only column, independent of which languages are selected. Note on KOMOS: UTMOS's Korean counterpart (https://github.com/upskyy/komos), only ever populated for `"ko"`. """ import math import os import re from datetime import datetime, timedelta import pandas as pd from huggingface_hub import hf_hub_download RESULTS_REPO = "hf-audio/tts_leaderboard_results" TOKEN_HUB = os.environ.get("TOKEN_HUB") or os.environ.get("HF_TOKEN") # ------------------------------------------------------------------ # Version registry # ------------------------------------------------------------------ # File name for each source key, constant across every version. _FILES = { "model_info": "model_info.csv", "seed_tts": "seed_tts.csv", "seed_tts_clone": "seed_tts_voice_clone.csv", "cv3": "cv3.csv", "cv3_clone": "cv3_voice_clone.csv", "minimax": "minimax.csv", "minimax_clone": "minimax_voice_clone.csv", "neyshekar": "neyshekar.csv", "neyshekar_clone": "neyshekar_voice_clone.csv", "ztts2_clean": "ztts2_mini_clean.csv", "ztts2_clean_clone": "ztts2_mini_clean_voice_clone.csv", "streaming": "streaming.csv", } def _version(label: str, revision: str, version: str) -> dict: """One VERSIONS entry: every file read at ``revision``, in ``RESULTS_REPO``, labelled with a semantic version number — see the comment above VERSIONS for how the number is chosen. """ return { "label": label, "version": version, **{ key: {"repo": RESULTS_REPO, "file": fname, "revision": revision} for key, fname in _FILES.items() }, } # Each entry maps a version id (DD-MM-YYYY) to a human-readable label and the # git revision (commit SHA, branch or tag) its CSVs were read at. # # "version" stamps each entry with a semantic version (https://semver.org/): # MAJOR — a foundational/breaking change (none yet). # MINOR — a dataset, normalizer, or measurement change: new or removed # datasets/languages, a scoring/normalization change, a new metric — # anything that changes what's measured or how. # PATCH — model-only additions/removals (a new serving engine or hardware # target for existing models counts as this too — it's just # another way to run a model, not a change to what's measured), # or a UI bugfix/feature that doesn't change what's measured # (e.g. a deeplink). # An entry mixing "add models" with a dataset/normalizer/measurement change # still bumps MINOR — the model additions just ride along with it. Shown in # the version dropdown and changelog (see get_version_choices/_changelog_text # below), and explained to users just below the dropdown (see VERSIONING_TEXT # in constants.py). # Rolling window for the "NEW" badge: models whose model_info.csv row first # appeared in any release within this many days of the viewed version's date # get the badge. Anchored on the viewed version, not today, so browsing an old # release still shows what was "new at the time". See Snapshot.new_models. NEW_BADGE_WINDOW_DAYS = 14 VERSIONS = { "24-11-2026": _version( label="Add joserui/tiny-voca-pt-pt (European Portuguese, pronuncia-pt front end), fixed voice, generated on CPU (RTFx not comparable with H200 GPU models). Replace FranciscoCarlosErra/alpa-es with marcosmaceo/tiny-voca-es (Spanish, a more typical Spanish tiny-voca port), fixed voice, CPU. Refresh Firoj112/pawp-tts-1.5m and pawp-tts-300k with the contributor's updated streaming code (1.04 pacing, comfort padding, 30 ms first chunk).", revision="5d4e3c400a7b88dbd52070a033c6fce0c2267c44", version="1.7.3", # PATCH: models/results only (Spanish port swap + European Portuguese). ), "23-11-2026": _version( label="Add 10 tiny-voca community-port TTS backends, fixed voice, generated on CPU (RTFx not comparable with H200 GPU models): apptor/apptor-tiny-tts (German), brenorb/tiny-broca (Portuguese), wite-tech/clarvia-tts-tiny (Turkish), RL10x/tiny-voca-hindi (Hindi), FranciscoCarlosErra/alpa-es (Spanish), ComputationalLinguisticsPlatform/tiny-voca-gr (Greek), oddadmix/tiny-voca-arabic (Arabic), egnch/tiny-voca-ru (Russian), DanielSuncost/tiny-voca-fr (French), gachimoto/tiny-voca-ja (Japanese, CER). Add drmhse/nano-edge-tts-standalone (English, 3.27M params, distilled from Kokoro-82M), fixed voice, CPU. Add gradium/phonon-31m-en and gradium/phonon-40m-en voice-cloning results on ZTTS2-Eval Mini (clean and in-the-wild, English, precomputed reference voices, CPU). Add Firoj112/pawp-tts-1.5m and Firoj112/pawp-tts-300k (English, pure-ONNX streaming, fixed voice, CPU; includes CPU TTFA/streaming).", revision="a606f43d9b7d0970018dbbe0b7951b3c8de3d145", version="1.7.2", # PATCH: models/results only. ), "21-11-2026": _version( label="Add software-mansion/Reverb-TTS for English, German, French, Spanish, Italian, Polish, and Portuguese, with and without voice cloning, plus streaming TTFA (A100, H200). Add mehdi-hf/cilla-mini and mehdi-hf/cilla-lite for Persian (Neyshekar and ZTTS2-Eval Mini clean), fixed voice, RTFx on CPU.", revision="e54063b735f6f1357f5b1714242b7e205feeae95", version="1.7.1", # PATCH: models only. ), "20-11-2026": _version( label="Add the ZTTS2-Eval Mini clean split (35 languages, FLEURS-R) as a new eval set, with and without voice cloning. Rescore Arabic and Korean on CV3-Eval and MiniMax (Arabic orthographic folding, Korean Latin-word tokens). Cap per-utterance WER/CER at 100% before pooling so a single runaway segment can't dominate a language's score.", revision="11d5c58bd8315732ba7e11af55e1497f4467c85f", version="1.7.0", # MINOR: new dataset + languages; Arabic/Korean rescore rides along. ), "16-11-2026": _version( label="Add owensong/Inflect-Micro-v3 and owensong/Inflect-Atom-v3 for English. Add n4ze3m/tiny-voca (F2, M2) for English (CPU).", revision="f04d35aac0d5b85a0c92a6bae98bf2dda05a94d5", version="1.6.3", # PATCH: models only. ), "14-11-2026": _version( label="Add ampixa/sanoTTS (heart, amy, heart-nano) for English (CPU). Add streaming TTFA for spybyscript/scyllasband (A100, H200, CPU). Add pnnbao-ump/VieNeu-TTS-v3-Nano for Vietnamese and spybyscript/scyllasband for English, Spanish, French, German, Italian, and Vietnamese. Add owensong/Inflect-Mini-v3 for English.", revision="beea3896e06141afb86734191a22ffa88e21c9c4", version="1.6.2", # PATCH: models + streaming additions (match production 1.6.2 until PR #133 is merged). ), "13-11-2026": _version( label="Add jordand/echo-tts-base for English (with voice cloning).", revision="cfb94bbf250029cf23082750b0b5fb0de8dfc5b3", version="1.6.1", # PATCH: model only. ), "12-11-2026": _version( label="Add Persian from a new Neyshekar eval set (shekar-ai/Neyshekar), add kjanh/KhanhTTS-OmniVoice and splendor1811/omnivoice-vietnamese for Vietnamese. Update Zyphra/ZONOS3-Mini: speaker-embedding voice cloning via the runtime server, expanded to 22 languages (CV3 ru + 13 MiniMax languages).", revision="e473170aaad165ea058990d8acbb0590e9f86302", version="1.6.0", ), "10-11-2026": _version( label="Add empero-ai/PiVo-1.4M, sahilmahendrakar/Paradee-8M-v1.3, and Zyphra/ZONOS3-Mini. Add deeplink for listening comparison of multiple models, e.g. `?listen=sahilmahendrakar/Paradee-8M-v1.3,empero-ai/PiVo-1.4M,Zyphra/ZONOS3-Mini,ConwayResearch/Underdog-Woof`", revision="9a9ac9de09ebb6c271df58200be4454a863dc3f8", version="1.5.3", ), "09-11-2026": _version( label="Add sulabhkatiyar/indic-tiny-tts-hindi. Add versioning (semantic version numbers, `?version=` deeplink) and a `?listen=gradium/phonon-31m-en`-style deeplink to go straight to the Listen tab for a specific model.", revision="54163c2e75a42d2d8078121526008a2b70ee22d4", version="1.5.2", ), "07-11-2026": _version( label="Add ConwayResearch/Underdog-Woof and Edge0/Audio8-TTS-Realistic-0.6b, add deeplinks like `?model=Edge0/Audio8-TTS-Realistic-0.6b` to select all languages supported by a specific model.", revision="b283e0ed8189890fe50f7b72ae2906e930d2c3da", version="1.5.1", # PATCH: models + a UI feature (deeplink) — nothing measured changes. ), "03-11-2026": _version( label="Add Vietnamese models: pnnbao-ump/VieNeu-TTS-v3-Turbo and contextboxai/Kokoro-Vietnamese. Vietnamese normalization fix for percent/decimals in WER scoring.", revision="ff843785d872f51f913fcb765309fcf2d0b93670", version="1.5.0", # MINOR: normalization change; models ride along. ), "02-11-2026": _version( label="Add inclusionAI/Ming-3.0-tts-0.5B. Add deeplinks like `?languages=hi` and `?languages=hi,fr` to redirect to specific languages. Add Korean KOMOS scores — see the 🤗 About tab.", revision="a8492d450508dd9d0286dd83cd8edb230363bfbe", version="1.4.0", # MINOR: new metric (KOMOS); model and deeplinks ride along. ), "30-10-2026": _version( label="Add LiquidAI/LFM3-Audio-2B, maya-research/maya2-native, ydqmkkx/GibbsTTS, gradium/phonon-40m-pt, and gradium/phonon-31m-en voice cloning.", revision="b48f392380f387c1bcd6a477ae82eef6299303bd", version="1.3.1", # PATCH: models only. ), "29-10-2026": _version( label="Add MiniMax TTS eval set for 14 new languages, update gradium/phonon results, and add audio.cpp targets for streaming.", revision="e1aa0c5a80d865c32b614041258be7b0473453c5", version="1.3.0", # MINOR: new dataset and languages. ), "27-10-2026": _version( label="Add multilingual checkpoints for gradium/phonon-40m-** and voice cloning results.", revision="6ebc60fdae194320567a48dde4d16a068bbf175f", version="1.2.1", # PATCH: models only. ), "21-10-2026": _version( label="Add fishaudio/drama-3, gradium/phonon-31m-en, and gradium/phonon-40m-en. Add UTMOS scores. Update H200 streaming results. Add missing Chinese split for hexgrad/Kokoro-82M (seed-tts-eval) and missing English split (seed-tts-eval) for FunAudioLLM/Fun-CosyVoice3-0.5B-2512 (RL).", revision="0a9c3bcd4035b26e0d74d3a64810008a2f811bb9", version="1.2.0", # MINOR: new metric (UTMOS); models ride along. ), "19-10-2026": _version( label="Normalizer fix: keep content within parentheses/brackets.", revision="2e43a082aed2932d52747a90df2692131ab16f4e", version="1.1.0", # MINOR: normalization change. ), "09-10-2026": _version( label="Add LiquidAI/LFM2.5-Audio-1.5B and sahilmahendrakar/Paradee-8M-v1.0. Add audio.cpp engine for streaming. Add A100 for streaming evals (and pause H200). Update MOSS TTS with better prompt.", revision="dd84b35e719440b53c06a9cef8e178e2c6950731", version="1.0.5", # PATCH: a new engine/hardware target is still just a new way to run a model. ), "30-09-2026": _version( label="Add Photon engine for streaming (Qwen3TTS and Kokoro).", revision="1a2bef5e1a2dd396a5802b30427439d695d4d111", version="1.0.4", # PATCH: new engine — still just a new way to run existing models. ), "29-09-2026": _version( label="Sync results programmatically (few instances of bad manual copies from initial version).", revision="f7de8c90ef3b8b8942a1014b56e5f953fc6717f4", version="1.0.3", # PATCH: pure bugfix. ), "18-09-2026": _version( label="Add IndexTeam/IndexTTS-2.5, vibevoice/VibeVoice-1.5B-hf, vibevoice/VibeVoice-7B-hf", revision="4b9b89ce115557b1976aec69379d265d50224801", version="1.0.2", # PATCH: models only. ), "14-09-2026": _version( label="Add tencent/AuK and tencent/AuK-Flash", revision="fed331160d61fc3d48c7386c2c34302dcfba78a9", version="1.0.1", # PATCH: models only. ), "08-09-2026": _version( label="Initial release! Two eval sets (Seed-TTS, CV3-Eval) across 9 languages, with and without voice cloning, plus per-language toggles, SIM, and Pareto plots.", revision="aadc7b97c867ae8000bd24fc2970ef9434f2edc7", version="1.0.0", # MAJOR: foundational initial release. ), } # "latest" is always an alias for the most recently added version above (the # first entry — new versions are prepended, not appended) — synthesized here # rather than hand-maintained as its own block, so it can never drift out of # sync with it. Kept as its own top-of-dict entry so it still reads "Latest # results" in the version dropdown instead of a raw date. (Same pattern as # the Open ASR Leaderboard: https://huggingface.co/spaces/hf-audio/open_asr_leaderboard/blob/main/init.py) _latest_version = next(iter(VERSIONS.values())) VERSIONS = {"latest": {**_latest_version, "label": "Latest results"}, **VERSIONS} DEFAULT_VERSION = "latest" # Which version this process serves. Overridable for local checks: # TTS_LEADERBOARD_VERSION=07-09-2026 python app.py ACTIVE_VERSION = os.environ.get("TTS_LEADERBOARD_VERSION") or DEFAULT_VERSION if ACTIVE_VERSION not in VERSIONS: print(f"[leaderboard_data] unknown version {ACTIVE_VERSION!r} — falling back to " f"{DEFAULT_VERSION!r}") ACTIVE_VERSION = DEFAULT_VERSION def get_version_choices() -> list[tuple[str, str]]: """``(label, value)`` pairs for a version selector, in registry order.""" return [ (f"{v['label']} (v{v['version']})" if vid == "latest" else f"(v{v['version']} · {vid}) {v['label']}", vid) for vid, v in VERSIONS.items() ] def version_id_for_semver(version_str: str | None) -> str | None: """The VERSIONS id (e.g. ``"07-11-2026"``) whose ``"version"`` field equals ``version_str`` (e.g. ``"1.11.0"``, a leading ``v``/``V`` is tolerated) — powers the ``?version=`` deeplink (same idea as the Open ASR Leaderboard's: https://huggingface.co/spaces/hf-audio/open_asr_leaderboard). Prefers a dated id over the ``"latest"`` alias when both match (they share a version number exactly when ``"latest"`` points at that same dated entry), so the result is always a real, stable id. ``None`` if nothing matches. """ version_str = (version_str or "").strip().lstrip("vV") if not version_str: return None match = None for vid, v in VERSIONS.items(): if v.get("version") == version_str: if vid != "latest": return vid match = vid # keep as a fallback in case no dated id also matches return match def _changelog_text() -> str: """Render the dated entries in ``VERSIONS`` as a changelog. One line per recorded snapshot, in registry order (newest first, per the convention noted above VERSIONS) — "latest" is skipped since it names the tip, not a fixed dated release. Recording a new snapshot only means editing VERSIONS; the changelog follows automatically. """ lines = ["\n"] for vid, v in VERSIONS.items(): if vid == "latest": continue date = datetime.strptime(vid, "%d-%m-%Y").strftime("%-d %B %Y") lines.append(f"- **{date}** (v{v['version']}) — {v['label']}\n") return "".join(lines) # Most recent entry first — app.py takes the first bold date as "Last updated". CHANGELOG_TEXT = _changelog_text() def source_for(source_key: str, version_id: str | None = None) -> dict: """Look up one ``{repo, file, revision}`` source in the given version. Falls back to the "latest" source when a dated version predates the file — a newly added CSV has no entry in older snapshots. """ version = VERSIONS.get(version_id or ACTIVE_VERSION, VERSIONS[DEFAULT_VERSION]) return version.get(source_key) or VERSIONS["latest"][source_key] # ------------------------------------------------------------------ # Languages # ------------------------------------------------------------------ # Display order for the language selectors (most-covered first). LANGUAGES = { "en": ("🇬🇧", "English"), "zh": ("🇨🇳", "Chinese"), "fr": ("🇫🇷", "French"), "es": ("🇪🇸", "Spanish"), "de": ("🇩🇪", "German"), "it": ("🇮🇹", "Italian"), "ja": ("🇯🇵", "Japanese"), "ko": ("🇰🇷", "Korean"), "ru": ("🇷🇺", "Russian"), "yue": ("🇭🇰", "Cantonese"), "pt": ("🇵🇹", "Portuguese"), "nl": ("🇳🇱", "Dutch"), "pl": ("🇵🇱", "Polish"), "cs": ("🇨🇿", "Czech"), "ro": ("🇷🇴", "Romanian"), "el": ("🇬🇷", "Greek"), "fi": ("🇫🇮", "Finnish"), "tr": ("🇹🇷", "Turkish"), "ar": ("🇸🇦", "Arabic"), "hi": ("🇮🇳", "Hindi"), "id": ("🇮🇩", "Indonesian"), "th": ("🇹🇭", "Thai"), "vi": ("🇻🇳", "Vietnamese"), "fa": ("🇮🇷", "Persian"), # Added with the ZTTS2-Eval Mini clean split (FLEURS-R). "uk": ("🇺🇦", "Ukrainian"), "sv": ("🇸🇪", "Swedish"), "da": ("🇩🇰", "Danish"), "nb": ("🇳🇴", "Norwegian"), "fil": ("🇵🇭", "Filipino"), "ms": ("🇲🇾", "Malay"), "hu": ("🇭🇺", "Hungarian"), "he": ("🇮🇱", "Hebrew"), "bg": ("🇧🇬", "Bulgarian"), "hr": ("🇭🇷", "Croatian"), "sk": ("🇸🇰", "Slovak"), "ca": ("🇦🇩", "Catalan"), } LANG_ORDER = list(LANGUAGES) DEFAULT_LANG = "en" def lang_display(code: str) -> str: """'en' -> '🇬🇧 English' (unknown codes fall back to the upper-cased code).""" info = LANGUAGES.get(code) return f"{info[0]} {info[1]}" if info else code.upper() def lang_flag(code: str) -> str: """'en' -> '🇬🇧' (used to prefix per-language table columns).""" info = LANGUAGES.get(code) return info[0] if info else code.upper() DISPLAY_TO_CODE = {lang_display(c): c for c in LANG_ORDER} def codes_from_display(displays) -> list[str]: """Map selector labels back to codes, keeping the canonical language order.""" picked = {DISPLAY_TO_CODE[d] for d in (displays or []) if d in DISPLAY_TO_CODE} return [c for c in LANG_ORDER if c in picked] # ------------------------------------------------------------------ # Datasets # ------------------------------------------------------------------ DATASETS = [ { "key": "seed_tts", "label": "Seed-TTS", "plain": "seed_tts", "clone": "seed_tts_clone", }, { "key": "cv3", "label": "CV3-Eval", "plain": "cv3", "clone": "cv3_clone", }, { "key": "minimax", "label": "MiniMax", "plain": "minimax", "clone": "minimax_clone", }, { "key": "neyshekar", "label": "Neyshekar", "plain": "neyshekar", "clone": "neyshekar_clone", }, { "key": "ztts2_clean", "label": "ZTTS2-Mini-clean", "plain": "ztts2_clean", "clone": "ztts2_clean_clone", }, ] DATASET_LABELS = [d["label"] for d in DATASETS] LABEL_TO_KEY = {d["label"]: d["key"] for d in DATASETS} DATASET_BY_KEY = {d["key"]: d for d in DATASETS} def keys_from_labels(labels) -> list[str]: """Map dataset selector labels back to keys, in the canonical dataset order.""" picked = {LABEL_TO_KEY[l] for l in (labels or []) if l in LABEL_TO_KEY} return [d["key"] for d in DATASETS if d["key"] in picked] # ------------------------------------------------------------------ # CSV parsing # ------------------------------------------------------------------ # "en WER" / "zh RTFx" / "fr SIM" / "en UTMOS" / "ko KOMOS" / "yue WER" # (MiniMax's Cantonese, the one 3-letter code) — but NOT "en SIM # (microsoft/wavlm-base-plus-sv)", and NOT the precomputed "avg WER" / # "avg RTFx" / "avg UTMOS" columns, which would otherwise also match a # 3-letter "lang" now that the length isn't fixed at 2. _METRIC_RE = re.compile(r"^(?!avg\s)(?P[a-z]{2,3})\s+(?PWER|RTFx|SIM|UTMOS|KOMOS)$") def _to_float(value): """Parse a CSV cell into a float, or None for blanks / non-numeric junk.""" if value is None: return None try: f = float(value) except (TypeError, ValueError): return None return None if pd.isna(f) else f def _yes(value) -> bool: return str(value).strip().lower() in {"yes", "y", "true", "1"} def _not_no(value) -> bool: """True unless the cell explicitly says no. The "batch inference" column is opt-out: only models known *not* to support it are marked, so a blank cell counts as supported. """ return str(value).strip().lower() not in {"no", "n", "false", "0"} def _clean_int_str(value, default="—") -> str: """'102' / '102.0' -> '102'; blanks -> default. CSV ints arrive as floats.""" f = _to_float(value) return str(int(f)) if f is not None else _clean_str(value, default) def _clean_str(value, default="—") -> str: if value is None or (isinstance(value, float) and pd.isna(value)): return default text = str(value).strip() return text if text and text.lower() != "nan" else default def _download(source_key: str, version_id: str | None = None) -> str | None: """Fetch one CSV at the revision the given version pins it to.""" source = source_for(source_key, version_id) try: return hf_hub_download( repo_id=source["repo"], filename=source["file"], repo_type="dataset", revision=source.get("revision"), token=TOKEN_HUB, ) except Exception as e: # noqa: BLE001 — the app must still boot without results rev = source.get("revision") or "main" print(f"[leaderboard_data] could not download {source['file']}@{rev}: {e}") return None def _parse_results(source_key: str, version_id: str | None = None) -> tuple[dict, list[str], dict]: """Parse one results CSV. Returns ``({model: {lang: {"wer", "rtfx", "sim", "utmos"}}}, [lang codes in file order], {model: note})`` — ``"utmos"`` only ever appears under ``"en"`` in practice (see the module docstring). Rows whose every metric is blank are dropped, so a model only shows up on the leaderboard once it actually has numbers. ``note`` is a free-text caveat about how a model was evaluated (e.g. run on different hardware than the rest) — present for only the rare row that has one. """ path = _download(source_key, version_id) if path is None: return {}, [], {} df = pd.read_csv(path) if "model" not in df.columns: print(f"[leaderboard_data] {source_key} has no 'model' column — skipping") return {}, [], {} # Column name -> (lang, metric), ignoring "avg *" and legacy-scale SIM columns. metric_cols = {} langs_present = [] for col in df.columns: m = _METRIC_RE.match(str(col).strip()) if not m: continue lang, metric = m.group("lang"), m.group("metric").lower() metric_cols[col] = (lang, metric) if lang not in langs_present: langs_present.append(lang) results = {} notes = {} for _, row in df.iterrows(): model = _clean_str(row["model"], default="") # Placeholder rows (bare URLs, notes-to-self) never carry metrics anyway, # but skipping them here keeps them out of the model universe entirely. if not model or model.startswith("http") or " " in model.split("/")[0]: continue per_lang = {} for col, (lang, metric) in metric_cols.items(): value = _to_float(row.get(col)) if value is None: continue per_lang.setdefault(lang, {})[metric] = value # A language entry without a WER is not a usable result. per_lang = {l: v for l, v in per_lang.items() if "wer" in v} if per_lang: results[model] = per_lang note = _clean_str(row.get("Note"), default="") or None if note: notes[model] = note langs = [c for c in LANG_ORDER if c in langs_present] langs += [c for c in langs_present if c not in langs] return results, langs, notes def _parse_model_info(version_id: str | None = None) -> dict: path = _download("model_info", version_id) if path is None: return {} df = pd.read_csv(path) info = {} for _, row in df.iterrows(): model = _clean_str(row.get("model"), default="") if not model or model.startswith("http"): continue info[model] = { "license": _clean_str(row.get("license")), "voice_cloning": _yes(row.get("voice cloning")), "batch_inference": _not_no(row.get("batch inference")), "n_languages": _clean_int_str(row.get("# languages")), "transformers": _yes(row.get("Transformers")), "size": _to_float(row.get("model size (B)")), } return info def _parse_streaming(version_id: str | None = None) -> dict: """Parse the streaming-mode benchmark CSV. One row per model — unlike the WER/RTFx results, streaming numbers aren't split by language or dataset. Most models are only measured on one piece of hardware; the other hardware's columns are blank for them. Both the "(p50)" (median) and "(p95)" TTFA columns are read here; the view layer ranks on p95 and drops a row that has no p95 for the selected hardware (see streaming_table). """ path = _download("streaming", version_id) if path is None: return {} df = pd.read_csv(path) out = {} for _, row in df.iterrows(): model = _clean_str(row.get("model"), default="") if not model or model.startswith("http"): continue out[model] = { "cpu_ttfa": _to_float(row.get("CPU TTFA [ms] (p50)")), "cpu_ttfa_p95": _to_float(row.get("CPU TTFA [ms] (p95)")), "cpu_rtfx": _to_float(row.get("CPU RTFx")), "h200_ttfa": _to_float(row.get("H200 TTFA [ms] (p50)")), "h200_ttfa_p95": _to_float(row.get("H200 TTFA [ms] (p95)")), "h200_rtfx": _to_float(row.get("H200 (RTFx)")), "a100_ttfa": _to_float(row.get("A100 TTFA [ms] (p50)")), "a100_ttfa_p95": _to_float(row.get("A100 TTFA [ms] (p95)")), "a100_rtfx": _to_float(row.get("A100 (RTFx)")), "streaming_api": _yes(row.get("Streaming API")), "note": _clean_str(row.get("Note"), default="") or None, # Some entries (e.g. a GGUF requant) run at a different size than # model_info.csv's checkpoint — this column overrides that when set. "size": _to_float(row.get("Size (B)")), } return out # ------------------------------------------------------------------ # One loaded version of the results # ------------------------------------------------------------------ class Snapshot: """Everything the app needs about a single version of the results. ``results[dataset_key][mode][model][lang] -> {"wer", "rtfx", "sim"}`` ``dataset_langs[dataset_key][mode] -> [lang codes]`` ``notes[dataset_key][mode][model] -> note text`` """ def __init__(self, version_id: str): self.version_id = version_id self.model_info = _parse_model_info(version_id) self.streaming = _parse_streaming(version_id) # Models newly added vs. the preceding dated release (empty for the oldest version, # and for "latest" we inherit the first dated version's deltas). "latest" is injected # at the head of VERSIONS, so the first key is either "latest" or the newest date; the # dated series starts at index 1 when "latest" is present. self._new_models_cache: set | None = None self.results: dict[str, dict[str, dict]] = {} self.dataset_langs: dict[str, dict[str, list[str]]] = {} self.notes: dict[str, dict[str, dict]] = {} for spec in DATASETS: self.results[spec["key"]] = {} self.dataset_langs[spec["key"]] = {} self.notes[spec["key"]] = {} for mode in ("plain", "clone"): res, langs, notes = _parse_results(spec[mode], version_id) self.results[spec["key"]][mode] = res self.dataset_langs[spec["key"]][mode] = langs self.notes[spec["key"]][mode] = notes # Models that have at least one result somewhere (the leaderboard universe). self.models_with_results = sorted( {m for ds in self.results.values() for mode in ds.values() for m in mode}, key=str.lower, ) # A model supports cloning if the metadata says so *or* it has cloning # results — the latter covers checkpoints that landed in the results # before model_info.csv. self.cloning_models = { m for m in self.models_with_results if self.model_info.get(m, {}).get("voice_cloning") or any(m in self.results[k]["clone"] for k in self.results) } missing = [m for m in self.models_with_results if m not in self.model_info] if missing: print(f"[leaderboard_data] {version_id}: models with results but no " f"model_info.csv row: {missing}") print( f"[leaderboard_data] {version_id}: {len(self.models_with_results)} models " f"with results ({len(self.cloning_models)} support voice cloning)" ) @property def new_models(self) -> set: """Model ids added in the ``NEW_BADGE_WINDOW_DAYS`` before this release's date. Baseline: the newest dated release whose date is on or before (anchor - window). The NEW set is then ``current model_info - baseline model_info`` — every model that first showed up in any release within the window. Lazy: the baseline fetch costs one extra model_info.csv download, so skip it until something asks. For "latest" we anchor on the newest dated release; for an unknown or oldest version the set is empty (no baseline to diff against). """ if self._new_models_cache is not None: return self._new_models_cache dated = [vid for vid in VERSIONS if vid != "latest"] resolved = dated[0] if self.version_id == "latest" else self.version_id try: idx = dated.index(resolved) except ValueError: self._new_models_cache = set() return self._new_models_cache try: anchor = datetime.strptime(resolved, "%d-%m-%Y").date() except ValueError: self._new_models_cache = set() return self._new_models_cache cutoff = anchor - timedelta(days=NEW_BADGE_WINDOW_DAYS) # First (newest) older release dated on or before the cutoff. baseline = None for older in dated[idx + 1:]: try: d = datetime.strptime(older, "%d-%m-%Y").date() except ValueError: continue if d <= cutoff: baseline = older break if baseline is None: self._new_models_cache = set() return self._new_models_cache previous = _parse_model_info(baseline) self._new_models_cache = set(self.model_info) - set(previous) return self._new_models_cache # Snapshots are immutable once loaded, so one per version is cached for the # lifetime of the process — switching back to a version is then free. _SNAPSHOTS: dict[str, Snapshot] = {} def load_version(version_id: str | None = None) -> Snapshot: """Return the (cached) snapshot for ``version_id``, loading it on first use.""" if version_id not in VERSIONS: version_id = ACTIVE_VERSION if version_id not in _SNAPSHOTS: _SNAPSHOTS[version_id] = Snapshot(version_id) return _SNAPSHOTS[version_id] # Warm the default version at import so the first page load is not slow. load_version(ACTIVE_VERSION) # ------------------------------------------------------------------ # Aggregation # ------------------------------------------------------------------ def languages_for(dataset_keys, clone: bool, version: str | None = None) -> list[str]: """Languages available for a set of datasets in the given mode.""" snap = load_version(version) mode = "clone" if clone else "plain" present = set() for key in dataset_keys: present.update(snap.dataset_langs.get(key, {}).get(mode, [])) return [c for c in LANG_ORDER if c in present] def languages_for_model(model: str, dataset_keys, clone: bool, version: str | None = None) -> list[str]: """Languages ``model`` itself has a usable result for, across the selected datasets/mode — the union, not an average over some other selection. Lets the "match a model's languages" preset set the language checkboxes to exactly this model's footprint, to compare it against every other model covering the same set (or more).""" snap = load_version(version) mode = "clone" if clone else "plain" present = set() for key in dataset_keys: present.update(snap.results.get(key, {}).get(mode, {}).get(model, {})) return [c for c in LANG_ORDER if c in present] def all_models(version: str | None = None) -> list[tuple[str, str]]: """Models that are **ranked** in the default view — complete for English across every dataset, without voice cloning — best WER first, each labelled with the languages it covers in that same mode across every dataset. The roster the "match a model's languages" preset picks from: a model that never earns a Rank in the default table (e.g. a result on only one of the three datasets) is left off, and showing each model's footprint up front saves a wasted click on one that doesn't add anything. Returns ``(label, model)`` pairs, ready as ``gr.Dropdown`` choices. """ dataset_keys = [spec["key"] for spec in DATASETS] ranked = [r["model"] for r in aggregate_rows(["en"], dataset_keys, False, version) if r["complete"]] return [ (f"{m} ({''.join(lang_flag(c) for c in languages_for_model(m, dataset_keys, False, version))})", m) for m in ranked ] def all_result_models(version: str | None = None) -> list[str]: """Every model id with at least one result in this version — the full universe, regardless of language, dataset or completeness. Unlike ``all_models`` (English-complete only), this is the roster for the Pareto "Highlight models" picker, which must reach a Portuguese-only port just as well as an English-complete one.""" return sorted(load_version(version).models_with_results, key=str.lower) def dataset_language_coverage(dataset_keys, clone: bool, version: str | None = None) -> dict: """``{dataset key: [language codes it covers, canonical order]}``, for captioning which of several selected datasets actually covers a given language — unlike ``languages_for``, this keeps the per-dataset split instead of the union.""" snap = load_version(version) mode = "clone" if clone else "plain" return { key: [c for c in LANG_ORDER if c in set(snap.dataset_langs.get(key, {}).get(mode, []))] for key in dataset_keys } def company_of(model: str) -> str: """``"k2-fsa/OmniVoice"`` -> ``"k2-fsa"``; a model with no org keeps its name.""" return model.split("/", 1)[0] if "/" in model else model def _mean(values): return sum(values) / len(values) if values else None def matches_search(model: str, search: str) -> bool: """Whether ``model`` matches a comma-separated search string (case-insensitive, OR'd — any term matching is enough). An empty/blank search matches everything.""" terms = [t.strip().lower() for t in (search or "").split(",") if t.strip()] return not terms or any(t in model.lower() for t in terms) def matches_size(size, max_size) -> bool: """Whether a model's size passes the size-filter slider. ``size`` or ``max_size`` of ``None`` always passes — a model with no reported size (most non-open-weight ones) is never hidden by the slider, which only narrows among models that do report one. """ return max_size is None or size is None or size <= max_size def size_bounds(version: str | None = None) -> tuple[float, float]: """``(0, max)`` bounds for the model-size filter slider, rounded up to one decimal so the top of the range is always reachable. ``(0, 1)`` if no model in this version reports a size.""" snap = load_version(version) sizes = [info["size"] for info in snap.model_info.values() if info.get("size") is not None] if not sizes: return 0.0, 1.0 return 0.0, math.ceil(max(sizes) * 10) / 10 def aggregate_rows(langs, dataset_keys, clone: bool, version: str | None = None) -> list[dict]: """Build one record per model with a result on at least one of ``langs``. Per-language values are macro-averaged across the selected datasets; the headline averages are then macro-averaged over ``langs`` — but a model only counts as **ranked** (``"complete"`` is ``True``) if it covers **all** of ``langs`` on **every** selected dataset, which keeps the ranking apples-to-apples: every *ranked* model is scored on exactly the same eval sets and languages. A model missing one or more of the selected languages still gets a record, with ``"complete"`` False and its headline ``wer``/``rtfx``/``sim`` averaged over just the languages it does cover — ``"coverage"`` (``(covered, len(langs))``) is what keeps that partial average from being mistaken for a complete one. ``rows`` sorts complete models first (best WER first, as before), then incomplete ones by coverage (widest first), then by that same partial WER. A dataset that does not cover a selected language at all (Seed-TTS has no French, say) simply sits out that language's average — only a *missing* result for a language the dataset does cover drops the language (not necessarily the whole model) from coverage. ``"utmos"`` is macro-averaged over the selected datasets' **English** score only (UTMOS22 wasn't trained on other languages — see the module docstring) — English need not be among ``langs`` for it to be computed, but it's still left as ``None`` when ``"complete"`` is False, same as ``wer``/``rtfx``/``sim``: a model that doesn't qualify for the ranking on the selected languages/datasets shouldn't still medal on UTMOS. ``"komos"`` is the same idea for **Korean** (see the module docstring) — always computed the same way regardless of ``langs``, left to the view to decide whether Korean is actually part of the current selection. Each record: ``{"model", "wer", "rtfx", "sim", "utmos", "komos", "note", "complete", "coverage", "per_lang": {lang: {...}}, "info": {...}}`` — ``per_lang`` only has an entry for a language the model actually has a usable result for. ``note`` joins every distinct caveat found across the selected datasets for this model (most models have none); shown regardless of ``complete``. """ snap = load_version(version) mode = "clone" if clone else "plain" covered = {k: set(snap.dataset_langs.get(k, {}).get(mode, [])) for k in dataset_keys} complete_rows, partial_rows = [], [] for model in snap.models_with_results: if clone and model not in snap.cloning_models: continue per_lang = {} complete = True for lang in langs: wers, rtfxs, sims = [], [], [] lang_complete = True for key in dataset_keys: entry = snap.results.get(key, {}).get(mode, {}).get(model, {}).get(lang) if not entry: if lang in covered[key]: lang_complete = False continue wers.append(entry["wer"]) if "rtfx" in entry: rtfxs.append(entry["rtfx"]) if "sim" in entry: sims.append(entry["sim"]) if not lang_complete or not wers: complete = False continue # no usable result for this language — leave it out of per_lang per_lang[lang] = { "wer": _mean(wers), "rtfx": _mean(rtfxs), "sim": _mean(sims), } if not per_lang: continue # nothing at all for this model across the selected languages utmos_values = [] for key in dataset_keys: v = snap.results.get(key, {}).get(mode, {}).get(model, {}).get("en", {}).get("utmos") if v is not None: utmos_values.append(v) # KOMOS (https://github.com/upskyy/komos) is UTMOS's Korean counterpart komos_values = [] for key in dataset_keys: v = snap.results.get(key, {}).get(mode, {}).get(model, {}).get("ko", {}).get("komos") if v is not None: komos_values.append(v) notes_seen = [] for key in dataset_keys: n = snap.notes.get(key, {}).get(mode, {}).get(model) if n and n not in notes_seen: notes_seen.append(n) info = snap.model_info.get(model, {}) row = { "model": model, "is_new": model in snap.new_models, "wer": _mean([v["wer"] for v in per_lang.values()]), "rtfx": _mean([v["rtfx"] for v in per_lang.values() if v["rtfx"] is not None]), "sim": _mean([v["sim"] for v in per_lang.values() if v["sim"] is not None]), "utmos": _mean(utmos_values) if complete else None, "komos": _mean(komos_values) if complete else None, "note": " / ".join(notes_seen) or None, "complete": complete, "coverage": (len(per_lang), len(langs)), "per_lang": per_lang, "info": info, } (complete_rows if complete else partial_rows).append(row) complete_rows.sort(key=lambda r: r["wer"]) partial_rows.sort(key=lambda r: (-r["coverage"][0], r["wer"])) return complete_rows + partial_rows def streaming_rows(version: str | None = None) -> list[dict]: """One record per model with a streaming-mode benchmark result. Each record: ``{"model", "cpu_ttfa", "cpu_ttfa_p95", "cpu_rtfx", "h200_ttfa", "h200_ttfa_p95", "h200_rtfx", "a100_ttfa", "a100_ttfa_p95", "a100_rtfx", "streaming_api", "note", "size"}`` (``"*_ttfa"`` is the p50 / median). ``size`` comes from streaming.csv's own "Size (B)" column when set there, else falls back to model_info.csv. Unlike ``aggregate_rows``, this isn't split by language/dataset — the streaming probe runs once per model — so there's no coverage filtering or sorting here; the view layer picks the hardware (CPU / H200 / A100) and ranks accordingly. """ snap = load_version(version) rows = [] for model, s in snap.streaming.items(): row = {"model": model, "is_new": model in snap.new_models, **s} if row["size"] is None: row["size"] = snap.model_info.get(model, {}).get("size") rows.append(row) return rows