A speech pipeline that only has to produce readable text takes an afternoon. One whose output drives decisions is harder: where a video clip may start, which party said a required disclosure, which half second of audio must be masked because a customer read out a card number. Every word then needs a time, every segment a reason to be trusted, and every speaker label a rating of how far to believe it.
Our answer is a layered pipeline that fits on consumer hardware: faster-whisper on CTranslate2 for recognition and word timestamps, Silero VAD gating the decoder, explicit hallucination flags instead of silent filtering, and torch-free diarisation with sherpa-onnx whose labels are smoothed and rated before anything consumes them. On an RTX 2060 with 6 GB it transcribes a 21.4-minute interview in about 55 seconds.
Below are the decisions from two of our prototypes, the AI Video Clipper and Call Quality AI, with thresholds and measurements from their repositories, runnable code, and where each layer fails.
Choose the model by device, then measure
faster-whisper reimplements Whisper on CTranslate2. Its README reports up to four times the speed of the reference implementation at the same accuracy, with less memory, and it ships Windows wheels without torch. That decided it: on our Python 3.14 machine no WhisperX release would install, because each required an older Python or pinned torch, CTranslate2 or PyAV versions that could not be met.
The clipper resolves auto by device: large-v3-turbo in float16 with CUDA, small in int8 on CPU. Explicit settings always win.
| Setting | Clipper on GPU | Clipper CPU fallback | Call QA adapter |
|---|---|---|---|
| Model | large-v3-turbo | small | tiny (default download) or base |
| Device and precision | CUDA, float16 | CPU, int8 | CPU, int8, 2 threads |
| Decoding | beam 5 | beam 5 | beam 1, temperature 0 |
| Speech gating | Silero via vad_filter |
Silero via vad_filter |
own energy VAD per channel |
| Language | detected once, then pinned | detected once, then pinned | pinned to id |
| Measured speed | 21.4 min in 55.6 s, about 23x real time | about 1x real time | not benchmarked |
Those numbers come from one machine (Windows 11, Ryzen 9 4900H, 15 GB RAM, RTX 2060 6 GB). In the end-to-end run, transcription took 54 seconds for the same file, about 24x real time, producing 3,652 words. At 1x an hour of audio costs a CPU an hour; at 23x it costs the GPU under three minutes. Real-time factor also varies with content, so measure on your own audio before sizing anything.
Make CUDA loadable on Windows before CTranslate2 asks
Current CTranslate2 needs cuBLAS for CUDA 12 and cuDNN 9. The nvidia-cublas-cu12 and nvidia-cudnn-cu12 wheels provide them, but on Windows they land in site-packages/nvidia/<lib>/bin, off the DLL search path; the faster-whisper README documents the pip route for Linux only. The clipper registers the directories once per process:
import os
import site
import sys
from pathlib import Path
_cookies: list[object] = [] # AddDllDirectory handles must live as long as the process
def register_cuda_dlls() -> None:
"""Make cuBLAS 12 and cuDNN 9 from the nvidia-*-cu12 wheels loadable on Windows."""
if sys.platform != "win32":
return
roots = [*site.getsitepackages(), *(p for p in sys.path if p.endswith("site-packages"))]
dirs = sorted({d.resolve() for r in roots for d in Path(r).glob("nvidia/*/bin") if d.is_dir()})
path = os.environ.get("PATH", "").split(os.pathsep)
known = {p.lower() for p in path}
for d in dirs:
_cookies.append(os.add_dll_directory(str(d)))
# CTranslate2 loads cuDNN's sub-libraries with LoadLibrary at run time, which
# searches PATH rather than the AddDllDirectory list, so register both.
fresh = [str(d) for d in dirs if str(d).lower() not in known]
os.environ["PATH"] = os.pathsep.join([*fresh, *path])
def cuda_available() -> bool:
register_cuda_dlls()
try:
import ctranslate2
return ctranslate2.get_cuda_device_count() > 0
except Exception: # no driver, a refused DLL or a CPU-only build: fall back to CPU
return False
Two details are easy to miss. The handle from os.add_dll_directory removes the directory when garbage collected, so keep it. And a positive device count proves little: in a scratch environment without the NVIDIA wheels, get_cuda_device_count() still reported the GPU, because it only needs the driver. cuBLAS and cuDNN load on first use, and a failure there can abort the process rather than raise. So registration precedes the first model load, and the clipper wraps decoding so a CUDA or cuDNN error tells the user to set asr.device: cpu.
Windows Smart App Control also refused the newest ctranslate2 4.9.0 binaries, so the project pins 4.8.3.
Gate the decoder with VAD and pin the language
Whisper decodes 30-second windows and was trained to emit text; give it a minute of hold music and it may oblige. In the paper's long-form ablation, adding voice activity detection lowered average word error rate from 10.6 to 10.2 across seven datasets. The clipper's decoding call:
from functools import cache
import numpy as np
from faster_whisper import WhisperModel
@cache
def load_model(cuda: bool) -> WhisperModel:
# One instance per process: loading large-v3-turbo costs seconds and VRAM.
if cuda:
return WhisperModel("large-v3-turbo", device="cuda", compute_type="float16")
return WhisperModel("small", device="cpu", compute_type="int8")
def transcribe(audio: np.ndarray, cuda: bool, vocabulary: list[str],
language: str | None = None) -> tuple[list[dict], str, float]:
segments, info = load_model(cuda).transcribe(
audio, # float32 mono at 16 kHz, never a file path
language=language, # None: detect once, then pin it
beam_size=5,
word_timestamps=True,
vad_filter=True,
vad_parameters={"threshold": 0.5, "min_speech_duration_ms": 250,
"min_silence_duration_ms": 300, "speech_pad_ms": 100},
condition_on_previous_text=False,
initial_prompt=(", ".join(vocabulary) + ".") if vocabulary else None,
)
out = [ # segments is a lazy generator: decoding happens in this loop
{
"start": s.start, "end": s.end, "text": s.text,
"avg_logprob": s.avg_logprob, "no_speech_prob": s.no_speech_prob,
"compression_ratio": s.compression_ratio,
"words": [(w.start, w.end, w.word, w.probability) for w in s.words or []],
}
for s in segments
]
return out, info.language, info.language_probability
vad_filter is off by default on WhisperModel.transcribe, and the default VAD options only remove silences of 2 seconds or more, with 400 ms of padding. The clipper tightens that to 300 ms and 100 ms. It also runs the same Silero model as its own stage, straight from the ONNX file in the faster-whisper wheel, streamed in blocks with the recurrent state carried across so memory stays bounded on multi-hour files. Those speech regions later clip the diarisation turns.
Three further choices come from failures, not taste:
- Arrays, in windows. faster-whisper 1.2.1's
decode_audiobroke with PyAV 19, so the pipeline passes decoded numpy audio. Long files go in 600-second windows, each cut at the quietest 0.4 seconds of its last 45, so no cut lands inside a word - Language detected once. The language from the first window that yields segments is passed to every later window, so a music intro or one code-switched sentence cannot flip the rest. The detection probability is stored with the transcript
- No previous-text conditioning. The ablation shows it helping slightly on average (10.2 to 10.0), but a misrecognised window then steers the next. We accept the small loss for loop resistance
Vocabulary hints carry a warning from the faster-whisper source. The clipper appends names and terms to initial_prompt, but with condition_on_previous_text=False the library resets the prompt after the first 30-second window, so the hint shapes only the first 30 seconds of each transcribe call. hotwords reaches every window's prompt (unless a prefix is set); for jargon spread through an hour, test it.
Word timestamps are estimates: clamp them and pad them
word_timestamps=True derives word times from cross-attention with dynamic time warping, on top of segment timestamps the paper quantises to 20 ms. They are inferred, not measured: words carry a leading space, punctuation merges into neighbours, and adjacent words can overlap or spill past their segment. The clipper clamps each start into the file and pushes it to at least the previous word's end, each end to at least its start, and drops the words of flagged segments, so downstream code sees a monotonic, non-overlapping sequence.
Punctuation is weaker than it looks. ASR often leaves fast conversational speech under-punctuated, and the effect varies by language, so sentence boundaries built only on ., ? and ! turn into long fragments. A pipeline can detect this, for instance by checking what share of clear pauses follow terminal punctuation, and end sentences at clear pauses instead. Test it on every language you serve, not only English.
When timestamps decide what gets hidden, error becomes a privacy budget. Call QA masks spoken numbers with a tone over the span its word timestamps give, padded by 0.25 seconds each side; a segment without word times spreads its characters evenly and pads by 0.6 seconds.
Flag hallucinations instead of silently dropping them
The Whisper paper names the signals. Decoding retries at higher temperatures when the average log probability is below -1 or the gzip compression ratio exceeds 2.4, and a window counts as silent only when the no-speech probability exceeds 0.6 and the log probability is also below -1, because the no-speech token alone was not reliable. faster-whisper applies the same defaults while decoding: it skips windows that meet the silence rule, and once fallback is exhausted it still emits its best attempt. Note that these scores belong to the 30-second window, shared by its segments. We re-check what comes out, with thresholds from our own configuration and a recorded reason:
import re
from collections.abc import Sequence
from dataclasses import dataclass
_PUNCT = re.compile(r"[^\w\s']+")
@dataclass(frozen=True)
class Segment:
text: str
avg_logprob: float
no_speech_prob: float
compression_ratio: float
def flag_segments(
segments: Sequence[Segment],
logprob_floor: float = -1.0,
no_speech_above: float = 0.6,
compression_above: float = 2.4,
loop_min_words: int = 5,
max_short_repeats: int = 2,
) -> list[str | None]:
"""One reason per segment ('empty', 'silence', 'compression', 'repeat') or None."""
flags: list[str | None] = []
prev, run = "", 0
for seg in segments:
norm = " ".join(_PUNCT.sub(" ", seg.text.lower()).split())
run = run + 1 if norm and norm == prev else 1
prev = norm
if not norm:
flags.append("empty")
elif seg.avg_logprob < logprob_floor and seg.no_speech_prob > no_speech_above:
flags.append("silence") # both signals agree, as in the Whisper paper
elif seg.compression_ratio > compression_above:
flags.append("compression")
elif run >= 2 and (len(norm.split()) >= loop_min_words or run > max_short_repeats):
flags.append("repeat") # a long sentence twice, or a short phrase three times
else:
flags.append(None)
return flags
| Flag | Signal | Catches | False positive risk |
|---|---|---|---|
| silence | log probability below -1 and no-speech above 0.6 | text invented over silence or music | quiet, mumbled real speech |
| compression | gzip ratio above 2.4 | one phrase looping inside a segment | repetitive speech, such as digits read aloud |
| repeat | same normalised text as the previous segment | decoder loops across segments | "There you go. There you go." (hence the run rule) |
| empty | nothing left after normalisation | stray punctuation | negligible |
Flagged segments stay in the transcript, marked dropped with their scores, and the run counts each reason. Their words are removed so nothing downstream quotes them, but an auditor can still see what the model produced and why it was set aside.
Thresholds are domain decisions. A card number read digit by digit can hold fifteen satu in a row, so Call QA's loop guard counts words: one word is a loop only past 20 repeats, a two-word phrase past 6, three words past 5, four past 4. It keeps the first occurrence and caps confidence at 0.3, because whatever was said during the loop was not transcribed.
Diarisation without torch
We compared pyannote's community-1 pipeline (CC-BY-4.0, gated on Hugging Face, requires torch) with sherpa-onnx running pyannote's segmentation-3.0 model (MIT) plus a speaker embedding model. The clipper defaults to sherpa-onnx with NeMo TitaNet-small embeddings: no account, no token, no torch. pyannote stays an optional backend.
The embedding and threshold were chosen by measurement. On a two-voice text-to-speech dialogue, TitaNet separated the speakers at clustering thresholds from 0.3 to 0.7, while 3D-Speaker models confused or over-split them. On the 21.4-minute interview, TitaNet at 0.7 produced 12 labels with span purity 0.936 in 200 seconds; eres2net produced 43 labels in 1,405 seconds. The threshold is a distance, so larger means fewer speakers. When the speaker count is known, pass it and clustering stops guessing.
Raw turns from either backend get the same post-processing: intersected with VAD speech, same-speaker turns under 0.3 seconds apart merged, turns under 0.1 seconds dropped, labels renamed SPEAKER_00 onwards, an overlap ratio computed, and a note that the labels are unverified clusters.
Budget for it: diarisation took 178 seconds on the CPU for the interview, roughly 7x real time by simple arithmetic and over three times as long as GPU transcription.
Treat speaker labels as hints
Each word takes the speaker whose turn overlaps it most, falling back to the nearest turn within 0.3 seconds. Then two checks: a smoothing pass for short flips, and a reliability rating for the whole file.
from collections import Counter
from dataclasses import dataclass
TERMINAL = (".", "?", "!")
@dataclass(frozen=True)
class Word:
text: str
start: float
end: float
def smooth_labels(words: list[Word], labels: list[str | None], max_words: int = 3,
max_s: float = 1.0, glue_gap_s: float = 0.3) -> list[str | None]:
"""Give a short label run glued into another speaker's unfinished phrase to that speaker."""
out, n, a = list(labels), len(words), 0
while a < n:
b = a + 1
while b < n and out[b] == out[a]:
b += 1
label = out[a]
if label is not None and b - a <= max_words and words[b - 1].end - words[a].start < max_s:
prev = out[a - 1] if a > 0 else None
nxt = out[b] if b < n else None
if (prev not in (None, label) and words[a].start - words[a - 1].end < glue_gap_s
and not words[a - 1].text.endswith(TERMINAL)):
out[a:b] = [prev] * (b - a)
elif (nxt not in (None, label) and words[b].start - words[b - 1].end < glue_gap_s
and not words[b - 1].text.endswith(TERMINAL)):
out[a:b] = [nxt] * (b - a)
a = b
return out
def labels_reliable(words: list[Word], labels: list[str | None], overlap_ratio: float) -> bool:
"""1 to 8 labels with >= 3% of talk time each, minor labels under 10%, little overlap."""
talk: Counter[str] = Counter()
for w, spk in zip(words, labels, strict=True):
if spk is not None:
talk[spk] += w.end - w.start
total = sum(talk.values())
main = [t for t in talk.values() if total and t / total >= 0.03]
return (overlap_ratio < 0.3 and 1 <= len(main) <= 8
and total > 0 and 1 - sum(main) / total < 0.10)
The smoothing rule is deliberately narrow. A run of at most three words and under a second, attached without a pause to an unfinished phrase, belongs to that phrase's speaker. A one-word reply after a pause, such as "Really?", survives. Testing it on hand-made sequences exposed a failure mode: it scans left to right, so when an utterance opens with three quick words and the next word is mislabelled, the opening run can be absorbed into the wrong speaker. When both neighbouring runs are short, no local rule can tell which one is the flip.
So the file-level rating matters more. On the interview, the 12 labels contained 3 main speakers. The clipper states the rating in the prompt of the language model that reads the transcript, so its reasoning can discount speaker identity when the labels are noisy; a stricter pipeline could also stop treating speaker changes as sentence boundaries when the rating fails. The same labels drive the crop in active-speaker reframing for vertical video, where a wrong label means a wrong face on screen.
The contact-centre variant: channels first, redaction before storage
Call QA, our QA prototype for Indonesian contact centres, solves diarisation without a model. Many recorders keep the agent and customer legs as the two channels of a stereo file, so speaker identity is the channel. A stereo pair that is really one mix written twice is treated as mono, and mono regions are marked as an unknown speaker with confidence 0.6. Its energy-based VAD treats a frame 20 dB quieter than the other leg, while that leg is speaking, as headset bleed.
The recogniser transcribes only those regions, grouped into chunks of at most 25 seconds so short turns get context. It pins the language to id, turns off faster-whisper's own VAD because the regions are already chosen, disables previous-text conditioning, and drops segments with no-speech probability above 0.6 and log probability below -1.
Then the step that shapes the architecture: redaction happens before anything is stored or scored. Raw recogniser output is its own type, and only the redaction step can produce the lines storage accepts. Every run of eight or more digits is redacted whatever its label; shorter runs are redacted when the preceding words name an OTP, PIN, card, ID, phone or account. A 1 kHz tone covers the padded span on both channels, and the rubric engine scores the redacted lines.
This is a prototype. Its demo uses 160 synthetic calls with speech-shaped, unintelligible audio and transcripts from a deterministic fixture recogniser; the real faster-whisper path is exercised by tests with the tiny model. We make no accuracy claim on real calls; that needs labelled recordings from the contact centre itself.
FAQ
Should we use WhisperX or pyannote instead?
If your stack already runs torch on a supported Python, both are reasonable; the clipper keeps pyannote as an optional backend. We chose the others because they installed cleanly on Windows with Python 3.14 and needed no gated token.
Can this run without a GPU?
Yes, at a cost. small in int8 ran at about 1x real time on the development CPU: fine for overnight batches or short calls, not for a queue of long recordings.
Checklist
- Pick model and precision by device, and measure real-time factor on your own audio
- On Windows, register the NVIDIA wheel directories with
os.add_dll_directoryand PATH before loading a model - Enable VAD with tighter silence settings than the default, and reuse the regions downstream
- Detect the language once, pin it, and store the probability
- Use
hotwordsfor vocabulary that must apply beyond the first 30 seconds - Clamp word timestamps into a monotonic sequence, and pad any span that hides data
- Flag segments with a reason instead of deleting them
- Smooth only short, glued label flips, and rate diarisation per file before trusting speaker changes
- When the recorder gives you separate channels, use them instead of a diarisation model
Primary references
- faster-whisper on GitHub: CTranslate2 implementation, CUDA 12 and cuDNN 9 requirements, word timestamps and the VAD filter
- Robust Speech Recognition via Large-Scale Weak Supervision: the Whisper paper, with the long-form decoding heuristics and their ablation in section 4.5
- Silero VAD: the voice activity detector bundled with faster-whisper, with ONNX runtime support
- sherpa-onnx speaker diarisation documentation: segmentation and embedding models for torch-free diarisation
Related reading
- Voice AI for Call Centres: Plan Handoffs and Recovery
- Evaluate AI Accuracy Before Deployment: A Buyer Checklist
The whole pipeline runs in our AI Video Clipper prototype, the contact-centre variant in Call Quality AI, and our AI solutions team builds the same layers into production speech systems.
