File size: 4,254 Bytes
434f7a8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env python3
"""Score the ASR models on the overlapping multilingual test set.

Primary metric = CONTENT-WORD RECALL: of the content words (len>=3) in each ground-
truth utterance, what fraction appear anywhere in the model's transcript. Reported
overall, per language, and as best/worst of the 3 overlapping speakers, plus how many
of the 3 speakers each model captures, plus speaker-count accuracy for diarizing models."""
import json, re, glob, statistics as st
from collections import defaultdict

BASE = "/mnt/nvme/uvp/overlap_testset"
RECALL_HIT = 0.30
ORDER = ["vibevoice", "parakeet", "qwen3", "nemotron_short", "nemotron_long", "chorus"]

def toks(t):
    return [w for w in re.findall(r"\w+", (t or "").lower(), re.UNICODE) if len(w) >= 3]

def recall(ref, hyp):
    r = set(toks(ref))
    if not r: return None
    return len(r & set(toks(hyp))) / len(r)

gt = {}
for f in glob.glob(f"{BASE}/clips/*.json"):
    d = json.load(open(f)); gt[d["clip_id"]] = d

models = {m: json.load(open(f"{BASE}/asr_out/{m}.json")) for m in ORDER
          if glob.glob(f"{BASE}/asr_out/{m}.json")}

overall = defaultdict(list); by_lang = defaultdict(lambda: defaultdict(list))
best3, worst3, captured, spk_pred = defaultdict(list), defaultdict(list), defaultdict(list), defaultdict(list)

for cid, g in gt.items():
    for m, out in models.items():
        hyp = out.get(cid, {}).get("text", "")
        rec = []
        for sp in g["speakers"]:
            r = recall(sp["transcript"], hyp)
            if r is None: continue
            rec.append(r); overall[m].append(r); by_lang[m][sp["language"]].append(r)
        if rec:
            best3[m].append(max(rec)); worst3[m].append(min(rec))
            captured[m].append(sum(1 for r in rec if r >= RECALL_HIT))
        ns = out.get(cid, {}).get("n_speakers")
        if ns is not None: spk_pred[m].append(ns)

def pct(x): return round(100*st.mean(x), 1) if x else None
def avg(x): return round(st.mean(x), 2) if x else None

LANGS = ["german","french","spanish","italian","dutch","portuguese"]
report = {"n_clips": len(gt), "speakers_per_clip": 3,
          "metric": "content-word recall (%), tokens len>=3", "models": {}}
for m in models:
    report["models"][m] = {
        "overall_recall_pct": pct(overall[m]),
        "recall_by_language_pct": {l: pct(by_lang[m][l]) for l in LANGS},
        "best_of_3_recall_pct": pct(best3[m]), "worst_of_3_recall_pct": pct(worst3[m]),
        "avg_speakers_captured_of_3": avg(captured[m]),
        "speaker_count_mean": avg(spk_pred[m]) if spk_pred[m] else None,
        "speaker_count_pct_exactly_3": pct([1 if n==3 else 0 for n in spk_pred[m]]) if spk_pred[m] else None,
        "speaker_count_MAE_vs_3": avg([abs(n-3) for n in spk_pred[m]]) if spk_pred[m] else None,
    }
json.dump(report, open(f"{BASE}/metrics.json","w"), indent=2, ensure_ascii=False)

LABEL = {"vibevoice":"VibeVoice-ASR","parakeet":"Parakeet v3","qwen3":"Qwen3-ASR",
         "nemotron_short":"Nemotron 80ms","nemotron_long":"Nemotron 1.12s","chorus":"Chorus-v1*"}
print(f"\n=== Overlapping multilingual ASR benchmark ({len(gt)} clips, 3 speakers/3 languages each) ===")
print("Metric: content-word recall % (how much of each ground-truth utterance the model captured)\n")
hdr = f"{'model':<16}{'overall':>8}{'best/3':>8}{'worst/3':>8}{'capt/3':>8}   " + "".join(f"{l[:3]:>6}" for l in LANGS)
print(hdr); print("-"*len(hdr))
for m in [x for x in ORDER if x in models]:
    r = report["models"][m]
    line = f"{LABEL[m]:<16}{r['overall_recall_pct']:>8}{r['best_of_3_recall_pct']:>8}{r['worst_of_3_recall_pct']:>8}{r['avg_speakers_captured_of_3']:>8}   "
    line += "".join(f"{(r['recall_by_language_pct'][l] or 0):>6}" for l in LANGS)
    print(line)
print("\nSpeaker-count (vs ground-truth 3):")
for m in [x for x in ORDER if x in models]:
    r = report["models"][m]
    if r["speaker_count_mean"] is not None:
        print(f"  {LABEL[m]:<16} mean={r['speaker_count_mean']}  exactly-3={r['speaker_count_pct_exactly_3']}%  MAE={r['speaker_count_MAE_vs_3']}")
    else:
        print(f"  {LABEL[m]:<16} (single-stream, no diarization)")
print("\n* Chorus-v1 is English-only & 2-speaker by design (out-of-domain here); fixed 2 streams.")
print(f"Wrote {BASE}/metrics.json")