--- license: apache-2.0 base_model: openai/whisper-base datasets: - Scicom-intl/semantic-vad-eot-emgs language: - ms - en pipeline_tag: audio-classification library_name: transformers tags: - end-of-turn-detection - turn-detection - semantic-vad - endpointing - voice-agent - livekit - onnx - whisper - telephony --- # Semantic VAD — Whisper-base end-of-turn detector (audio only) The whisper-base sibling of [`Scicom-intl/semantic-vad-eot-whisper-tiny`](https://huggingface.co/Scicom-intl/semantic-vad-eot-whisper-tiny): same recipe, same input contract, same data, a 2.5× larger encoder. Given the last 8 seconds of a caller's 16 kHz audio it returns `p(end of turn)` — finished speaking vs paused mid-sentence — with no transcript. **20 M parameters · int8 ONNX 24 MB · roughly twice the compute of the tiny model** (int8 69 ms vs 34 ms per prediction measured back to back on the same busy CPU; the tiny model runs ≈30 ms idle on one thread). It ranks turns better than the tiny model (AUC 0.88 vs 0.84 in the pipeline, 0.85 / 0.87 / 0.98 vs 0.80 / 0.81 / 0.97 offline at 0 / 0.2 / 0.6 s into a pause) — worth it when CPU is not the constraint or when you want a stricter threshold; otherwise use the tiny model, which we recommend for production. ## Results **In a real LiveKit Agents 1.8 pipeline** (Silero VAD → turn detector → endpointing, no STT, 300 recorded telephony turns, LiveKit defaults: VAD silence 0.55 s, `min_delay` 0.5 s, `max_delay` 3.0 s): | turn detector | latency p50 / p90 | turns cut off | finished turns on the fast path | AUC (eot vs hold) | |---|---:|---:|---:|---:| | VAD only | 0.63 / 0.71 s | 14.3 % | – | – | | smart-turn-v3, threshold 0.5 | 0.65 / 3.04 s | 10.0 % | 82 % | 0.74 | | tiny variant, threshold 0.5 | 0.64 / 0.74 s | 10.0 % | 95 % | 0.84 | | **this model, threshold 0.3** | **0.64 / 0.74 s** | **9.7 %** | **96 %** | **0.88** | | this model, threshold 0.5 | 0.65 / 2.93 s | 9.3 % | 90 % | 0.88 | The int8 export's scores sit a little lower than the tiny model's (recall at 0.5 is 0.87 vs 0.92 at the pause start), so **0.3 is this model's equivalent of the tiny model's 0.5**; at 0.5 it is stricter — one more cut-off avoided, but 10 % of finished turns wait for `max_delay`. One cut-off turn in 300 separates it from the tiny model at matched fast-path share, which is within noise. **Offline, at fixed cut points relative to the start of each pause** (AUC, same 300 turns, every pause): | cut relative to pause start | −0.4 s | −0.2 s | 0.0 s | +0.2 s | +0.6 s | |---|---:|---:|---:|---:|---:| | smart-turn-v3 | 0.60 | 0.62 | 0.63 | 0.65 | 0.69 | | tiny variant (int8) | 0.72 | 0.78 | 0.80 | 0.81 | 0.97 | | **this model (int8)** | **0.77** | **0.82** | **0.85** | **0.87** | **0.98** | Score smoothness along a pause matches the tiny model (local std 0.044 over 200 ms, threshold flips 1.7 % per 20 ms step; smart-turn-v3 0.124 / 9.8 %). ## Files | file | what | |---|---| | `onnx/model.int8.onnx` | MatMul-only dynamic int8, 24 MB | | `onnx/model.fp32.onnx` | fp32 export, 81 MB; max abs Δp vs PyTorch 1e-6 | | `onnx/export_report.json` | sizes, parity vs PyTorch, latency at export time | | `encoder/` | fine-tuned Whisper-base encoder, HF format (`config.json`, `model.safetensors`, bf16) | | `eot_head.pt` | `{"state_dict": LayerNorm→Linear(512,256)→GELU→Linear(256,1), "pooling": "last5"}` | | `eot_window.json` / `preprocessor_config.json` | the input contract: 8 s window, 80 mel bins, 16 kHz, no mel normalisation, mean of the last 5 encoder frames | | `training_summary.json` | best step, validation AUC history | Input: `input_features` `[batch, 80, 800]` float32 — Whisper log-mel of the **last 8 s of audio, left-padded with zeros when shorter**, `do_normalize=False`. Output: `probability` `[batch, 1]`, already through the sigmoid. ## Usage Identical to the tiny model — substitute the repo id. In short (ONNX, no torch): ```python import numpy as np, onnxruntime as ort from huggingface_hub import hf_hub_download from transformers import WhisperFeatureExtractor REPO, SR, WINDOW = "Scicom-intl/semantic-vad-eot-whisper-base", 16000, 8 * 16000 opts = ort.SessionOptions(); opts.intra_op_num_threads = 1 sess = ort.InferenceSession(hf_hub_download(REPO, "onnx/model.int8.onnx"), opts, providers=["CPUExecutionProvider"]) fe = WhisperFeatureExtractor(feature_size=80, sampling_rate=SR, chunk_length=8) def p_end_of_turn(pcm: np.ndarray) -> float: """pcm: float32 in [-1, 1] at 16 kHz, the caller's audio up to *now* (any length).""" pcm = np.asarray(pcm, dtype=np.float32) if pcm.size and np.abs(pcm).max() > 1.5: # int16-scale samples -> unit float pcm = pcm / 32768.0 pcm = pcm[-WINDOW:] if len(pcm) >= WINDOW else np.pad(pcm, (WINDOW - len(pcm), 0)) feats = fe([pcm], sampling_rate=SR, return_tensors="np", padding="max_length", max_length=WINDOW, truncation=True, do_normalize=False)["input_features"].astype(np.float32) return float(sess.run(None, {"input_features": feats})[0].reshape(-1)[0]) ``` Use `p ≥ 0.3` as "the turn is over" for the operating point in the table above. The PyTorch loading snippet (a `WhisperEncoder` subclass that accepts the 8 s window + the 3-layer head) is on the tiny model's card and works unchanged with this repo id (`d_model` 512). ## Training Same as the tiny model: `Scicom-intl/semantic-vad-eot-emgs` (private call-centre telephony, Malay/English, customer + agent channels), all train + validation files, early stopping (patience 3) on a fixed 4 000-cut sample of the test split — the pipeline benchmark's 300 turns come from that split too, so the numbers are in-distribution. Six cut offsets per pause drawn uniformly in [−0.4, +1.2] s (never a fixed grid — it gets memorised), 8 s left-padded window, mean of the last 5 encoder frames → `EoTHead`. `openai/whisper-base` encoder (6 layers, d 512) fully fine-tuned in bf16, batch 128, AdamW lr 5e-5 constant after warm-up. Early-stopped at step 32 000 (validation AUC 0.877 on uniform cuts; tiny: 0.859 at step 8 000). ONNX via `torch.onnx.export` at the fixed 800-frame input, MatMul-only dynamic int8. ## Limitations As for the tiny model: telephony Malay/English only (matches, does not beat, the VAD baseline on Malay read speech); expects the raw phone channel (noise cancellation in front of it hurt); feed unit-scale float audio; query it after a short VAD silence, not on every frame; a 300-turn sample stands behind the pipeline numbers. ## License Apache-2.0 (the Whisper encoder it fine-tunes is Apache-2.0). The training data is not released.