#!/usr/bin/env python3 """Collect per-model metrics.json files into one comparison table. Reads whatever `benchmark_whisper.sh` produced and prints the models in WER order, plus the reference figure from the paper this reproduces. """ from __future__ import annotations import json import sys from pathlib import Path # arXiv:2510.23319 table 4: the best of eight Whisper variants on 355 # Levantine child utterances. Different corpus and different task -- single # words here against connected speech there -- so this is context for the # scale of the gap, not a like-for-like target. PAPER_BEST = ("Large-v3 on Arabic Little STT", 0.66) def main(root: Path) -> int: rows = [] for metrics_path in sorted(root.glob("*/metrics.json")): metrics = json.loads(metrics_path.read_text(encoding="utf-8")) overall = metrics["overall"] rows.append( { "model": metrics["model"], "wer": overall["wer"], "cer": overall["cer"], "utterances": metrics.get("evaluated_utterances", overall.get("utterances")), } ) if not rows: print(f"No metrics found under {root}", file=sys.stderr) return 1 rows.sort(key=lambda row: row["wer"]) label, paper_wer = PAPER_BEST paper_row = f"paper: {label}" width = max(max(len(row["model"]) for row in rows), len(paper_row)) print() print(f"{'model'.ljust(width)} {'WER':>7} {'CER':>7} {'utts':>6}") print("-" * (width + 25)) for row in rows: print( f"{row['model'].ljust(width)} {row['wer']:7.3f} " f"{row['cer']:7.3f} {row['utterances']:6d}" ) print("-" * (width + 25)) print(f"{paper_row.ljust(width)} {paper_wer:7.3f}") print() print("Lower is better. WER above 1.0 means the model emitted more wrong") print("words than the reference had -- normal when a model narrates around a") print("single-word prompt.") return 0 if __name__ == "__main__": raise SystemExit(main(Path(sys.argv[1] if len(sys.argv) > 1 else "reports/benchmark")))