Files
Abolfazl Ranjbaran 0a69c90c7a feat: segments timeline, VTT/JSON exports, bot completion notifications, weekly benchmark gate
Closes the biggest feature gaps found in a full inventory pass:

- GET /jobs/{id} now returns the per-segment timeline (start / end /
  speaker / text, 1-based position) the database always stored but never
  exposed; the dashboard renders a timestamped, speaker-labelled
  transcript view with copy-to-clipboard and a delete button (the DELETE
  endpoint existed and was tested, but no UI called it)
- New transcript exports: WebVTT and structured JSON; the
  OpenAI-compatible endpoint completes its response_format set with vtt
- Engine decoding knobs: WHISPER_BEAM_SIZE and WHISPER_INITIAL_PROMPT
  (the v1.4 initial-prompt lexicon item)
- The Telegram bot now delivers what it always promised: a persisted
  completion notifier pushes the transcript in Telegram-sized chunks (or
  a failure notice) the moment the backend finishes; jobs stuck over six
  hours are released instead of leaking
- Weekly benchmark workflow re-runs the fixture against the committed
  baseline (benchmarks/results/baseline.json) and fails on a >1 WER point
  regression; benchmark_wer.py gained --archive / --baseline /
  --max-regression with the gate logic unit-tested in
  benchmarks/regression.py

92 tests passing (new: segments+exports, vtt, engine options, notifier
decision logic, store tracking and legacy migration, regression gate);
ruff and mypy clean; next build clean
2026-11-22 18:21:16 +00:00

42 lines
1.4 KiB
Python

"""WER regression gate for the benchmark fixture.
Deliberately free of heavy imports (no jiwer / no faster-whisper) so CI and
tests can exercise the gate logic without downloading model weights.
"""
import json
from pathlib import Path
def load_baseline(path: str | Path) -> dict[str, float]:
"""Read a baseline file ({"models": {"<name>": {"wer": ...}}}) into {name: wer}."""
data = json.loads(Path(path).read_text(encoding="utf-8"))
return {
name: float(entry["wer"])
for name, entry in data.get("models", {}).items()
if isinstance(entry, dict) and "wer" in entry
}
def check_regression(
runs: list[dict], baseline: dict[str, float], max_points: float
) -> list[str]:
"""Human-readable regressions for runs whose model has a recorded baseline.
`max_points` is the tolerated WER increase in percentage points; a run
that is better than the baseline never fails the gate.
"""
problems: list[str] = []
for run in runs:
recorded = baseline.get(str(run.get("model")))
if recorded is None:
continue
delta = (float(run["wer"]) - recorded) * 100 # percentage points
if delta > max_points:
problems.append(
f"{run['model']}: WER {float(run['wer']) * 100:.1f}% is {delta:.1f} "
f"points above the recorded baseline {recorded * 100:.1f}% "
f"(allowed: +{max_points:.1f})"
)
return problems