From 18d1bd49ed981895020a94ae15e316261a79d3c0 Mon Sep 17 00:00:00 2001 From: Wei Chu <6074946+weiwchu@users.noreply.github.com> Date: Sun, 22 Nov 2026 22:40:25 -0800 Subject: [PATCH] olign_v1: ask for phone times on every upload, and stop on aligned words without phones Olign v1.2.1 returns word times alone unless a job sends the form field timestamps=phone, and FA-Bench scores the phone tier. Both tracks upload through olign_v1_call, so the field goes there, outside the recipe options, so the cache key and every cached answer stay. Today's production ignores the field. A Track 1 answer whose words carry no phones now raises instead of scoring an empty phone tier. Track 2 is scored on words, and a few of its genuine answers name words without phones, so it keeps them. All 865,231 cached Olign answers on this machine still parse. --- CHANGELOG.md | 5 +++++ fabench/aligners/olign_v1/test/test_olign_v1.py | 17 +++++++++++++++++ fabench/timestamp_asrs/cloud/providers.py | 14 +++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 867923d..2d1c093 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,11 @@ be compared only when no such change lies between them. docs and recipe comments now call it Olign v1, Olewave's job API, since it runs Olewave's current release. Its published rows keep the name Olign 1.0, the release that produced them. No number moves. +- Every Olign v1 upload, on both tracks, asks for phone times with the form + field `timestamps=phone`. Olign v1.2.1 returns word times alone unless a job + asks, and the phone tier is scored. A Track 1 answer whose words carry no + phones now stops the run instead of scoring an empty phone tier. Olign's + answers and every cached result are unchanged, so no number moves. ## [2.1.0] - 2026-11-10 diff --git a/fabench/aligners/olign_v1/test/test_olign_v1.py b/fabench/aligners/olign_v1/test/test_olign_v1.py index 5af34c5..f6b4782 100644 --- a/fabench/aligners/olign_v1/test/test_olign_v1.py +++ b/fabench/aligners/olign_v1/test/test_olign_v1.py @@ -67,6 +67,7 @@ def test_track1_sends_the_transcript_and_reads_words_and_phones(audio, tmp_path, assert post["headers"]["User-Agent"] == "fa-bench-olign/1" assert b'name="transcript"' in post["data"] and b"in wage" in post["data"] assert b'name="audio"' in post["data"] + assert b'name="timestamps"\r\n\r\nphone\r\n' in post["data"] assert poll["url"] == "https://api.olewave.com/olign/v1/j1" assert [(w.label, w.start, w.end) for w in out.words] == [("in", 0.14, 0.31), ("wage", 0.31, 0.75)] assert out.words[0].conf == pytest.approx(0.98) @@ -88,6 +89,7 @@ def test_track2_sends_audio_alone(audio, tmp_path, monkeypatch, server): out = _make(OlignV1ASR, tmp_path, monkeypatch).align(audio, "the reference is never sent") assert b'name="transcript"' not in calls[0]["data"] assert b"the reference is never sent" not in calls[0]["data"] + assert b'name="timestamps"\r\n\r\nphone\r\n' in calls[0]["data"] assert out.meta["transcript_source"] == "asr" assert [w.label for w in out.words] == ["in", "wage"] @@ -103,6 +105,21 @@ def test_no_speech_is_an_empty_answer_and_is_cached(audio, tmp_path, monkeypatch assert a.align(audio, "").meta["cached"] is True and len(calls) == n +def test_words_without_phones_fail_loudly(audio, tmp_path, monkeypatch, server): + _, state = server + state["final"] = {**DONE, "result": {"words": [{**w, "phones": []} for w in DONE["result"]["words"]]}} + with pytest.raises(Exception, match="2 words came back with no phones"): + _make(OlignV1, tmp_path, monkeypatch).align(audio, "in wage") + + +def test_track2_words_without_phones_are_kept(audio, tmp_path, monkeypatch, server): + _, state = server + state["final"] = {**DONE, "transcript_source": "asr", + "result": {"words": [{**w, "phones": []} for w in DONE["result"]["words"]]}} + out = _make(OlignV1ASR, tmp_path, monkeypatch).align(audio, "") + assert [w.label for w in out.words] == ["in", "wage"] and out.phones == [] + + def test_any_other_failure_raises(audio, tmp_path, monkeypatch, server): _, state = server state["final"] = {"state": "failed", "log_tail": "pipeline crashed"} diff --git a/fabench/timestamp_asrs/cloud/providers.py b/fabench/timestamp_asrs/cloud/providers.py index 05960c7..472b13d 100644 --- a/fabench/timestamp_asrs/cloud/providers.py +++ b/fabench/timestamp_asrs/cloud/providers.py @@ -309,6 +309,10 @@ def elevenlabs_fa_parse(r: dict, model: str, opts: dict) -> tuple[list[Word], di #: The job's own word for a recording with nothing in it. A real answer, so #: it is kept and cached as an empty result rather than retried on every run. OLIGN_NO_SPEECH = "no speech recognized" +#: Olign answers with word times alone unless a job asks for phones, and the +#: phone tier is scored, so every upload asks. Sent as a form field and kept +#: out of the recipe options, so the cache key, and every cached answer, stays. +OLIGN_TIMESTAMPS = "phone" def olign_v1_call(blob: bytes, path: str, model: str, opts: dict, key: str, @@ -325,7 +329,7 @@ def olign_v1_call(blob: bytes, path: str, model: str, opts: dict, key: str, text = str(opts.get("text") or "").strip() if text: files["transcript"] = ("transcript.txt", "text/plain", text.encode("utf-8")) - ctype, body = multipart({}, files) + ctype, body = multipart({"timestamps": OLIGN_TIMESTAMPS}, files) _note("endpoint", base); _note("api_version", "v1") created = request_json(base, method="POST", data=body, headers={**auth, "Content-Type": ctype}, @@ -374,6 +378,14 @@ def olign_v1_parse(r: dict, model: str, opts: dict) -> tuple[list[Word], dict, l ps = p.get("score") phones.append([str(p.get("ph") or ""), float(p["begin"]), float(p["end"]), None if ps is None else float(ps) / 100.0]) + # Aligned words with no phones at all mean the request for phones never + # reached the job. Scoring that would report an empty phone tier as Olign's, + # so stop. Only for the given transcript: Track 2 scores words alone, and a + # few of its genuine answers name words without phones. + spoken = [w for w in res.get("words") or [] if str(w.get("word") or "").strip()] + if r.get("transcript_source") == "client" and spoken and not any(w.get("phones") for w in spoken): + raise CloudASRError(f"olign_v1: {len(spoken)} words came back with no phones, " + f"so timestamps={OLIGN_TIMESTAMPS} did not reach the job") meta = {"api_model": model, "transcript_source": r.get("transcript_source"), "job_state": r.get("state")} if r.get("state") == "failed":