DS DevShelfHub Projects · AI tools
Cheatsheets / Whisper
Cheatsheet · AI frameworks

Whisper: Transcription, faster-whisper, VAD and Diarization Reference Guide

By DevShelfHub

OpenAI Whisper, faster-whisper, whisper.cpp, HF pipelines, word-level timestamps, VAD, diarization, languages — the speech-to-text surface across runtimes.

106 items 8 min ASR Timestamps VAD

Start hereQuick start · 6 you’ll reach for daily

Loadwhisper.load_model("base")
Transcribemodel.transcribe("a.mp3")
Translatetask="translate" → English
Word timesword_timestamps=True
Fasterfaster-whisper · int8/fp16
Long audiovad_filter=True · chunk_length_s=30

Target versions · paceVersions

Targets: openai-whisper ≥ 20240930 faster-whisper ≥ 1.0 transformers ≥ 4.45 whisper.cpp ≥ 1.6

Same model weights, three runtimes worth knowing. openai-whisper is the reference PyTorch implementation — slowest but the one papers cite. faster-whisper wraps the CTranslate2 backend with int8 / fp16 quantization — ~4× faster, same accuracy. HF transformers exposes Whisper through the standard pipeline / Trainer API — the path for fine-tuning. whisper.cpp is a C++ port with no Python dependency — great for desktop / mobile / edge. large-v3 is the current strongest checkpoint; large-v3-turbo trades a small quality drop for ~8× speed.

Install · runtimesSetup

bash
# Pick ONE runtime — they all read the same .pt weights but ship different APIs

# 1 · Reference implementation (PyTorch, slow but matches paper)
pip install -U openai-whisper

# 2 · faster-whisper — CTranslate2 backend, 4× faster on CPU/GPU
pip install faster-whisper

# 3 · Hugging Face transformers — pipeline / Trainer / fine-tuning
pip install transformers accelerate

# 4 · whisper.cpp — C++ build, CPU + Apple Metal, no Python required
brew install whisper-cpp           # or build from source

# ffmpeg is required by every Python runtime
brew install ffmpeg                # macOS
apt install ffmpeg                 # Debian / Ubuntu

Pick the right oneModels

tiny / tiny.en39M params. ~1GB VRAM. Real-time on CPU. Lowest accuracy.
base / base.en74M. ~1GB. Strong CPU default.
small / small.en244M. ~2GB. Good quality bump.
medium / medium.en769M. ~5GB. Where quality starts to be production-grade.
large-v1, large-v2, large-v31550M. ~10GB. v3 is the current best multilingual.
large-v3-turbo809M. ~6GB. Decoder pruned to 4 layers; ~8× faster, near-large accuracy.
.en suffixEnglish-only. Slightly better on English. Drop the suffix for multilingual.
Sizing rule: pick the largest that fits your latency budget. For batch transcription, use large-v3; for streaming or edge, use small or large-v3-turbo.

openai-whisperReference API

import whisperThe reference PyTorch implementation.
model = whisper.load_model("base", device="cuda")Loads weights to ~/.cache/whisper/ on first call.
model.transcribe("a.mp3")High-level call. Auto-detects language. Returns dict.
result["text"], result["segments"], result["language"]Full text, per-segment metadata, detected language.
language="en", task="transcribe" | "translate"Pin language; translate forces English output.
word_timestamps=TrueAdds segment["words"] with per-word timing.
initial_prompt="acronyms: GPU, RAG, LCEL"Seed the decoder. Improves rare vocab.
fp16=True, beam_size=5, temperature=0.0Half precision, beam search, deterministic.
no_speech_threshold=0.6, logprob_threshold=-1.0Heuristics for trimming silent or low-confidence segments.
condition_on_previous_text=FalseReset context between segments. Helps if hallucination loops appear.

Worked example

python
import whisper

# Loads weights to ~/.cache/whisper/ on first call
model = whisper.load_model("base", device="cuda")  # cpu, cuda, mps

result = model.transcribe(
    "interview.mp3",
    language="en",          # pin language to skip detection
    task="transcribe",      # or "translate" → English
    fp16=True,              # half precision on GPU
    temperature=0.0,        # deterministic
    no_speech_threshold=0.6,
    beam_size=5,
    word_timestamps=True,
)

print(result["text"])
for seg in result["segments"]:
    print(f"[{seg['start']:.2f} → {seg['end']:.2f}] {seg['text']}")

CTranslate2 backendfaster-whisper

from faster_whisper import WhisperModelDrop-in alternative. Same weights, different runtime.
WhisperModel("large-v3", device="cuda", compute_type="float16")GPU half precision. The default in prod.
compute_type="int8" | "int8_float16" | "float16" | "float32"Quantization knob. int8 = best CPU; int8_float16 = best GPU memory.
segments, info = model.transcribe(…)segments is a generator. Inference runs as you iterate.
info.language, info.language_probability, info.durationDetection + audio metadata.
vad_filter=True, vad_parameters={"min_silence_duration_ms":500}Built-in Silero VAD. Trims silence before inference.
word_timestamps=TruePer-word timing in seg.words.
model = BatchedInferencePipeline(model)Batched transcription for long files. Big throughput win.
model.transcribe(…, hotwords="LangGraph DevShelf")Boost specific phrases. Bias decoder probabilities.

Worked example

python
from faster_whisper import WhisperModel

# int8 = best speed/quality tradeoff on CPU; "float16" on GPU
model = WhisperModel(
    "large-v3",
    device="cuda",
    compute_type="float16",          # int8, int8_float16, float16, float32
)

segments, info = model.transcribe(
    "interview.mp3",
    language="en",
    beam_size=5,
    vad_filter=True,                 # built-in Silero VAD
    vad_parameters={"min_silence_duration_ms": 500},
    word_timestamps=True,
)

print(f"Detected: {info.language} ({info.language_probability:.2%})")

# segments is a generator — iterate to actually run inference
for seg in segments:
    print(f"[{seg.start:.2f} → {seg.end:.2f}] {seg.text}")
    for w in seg.words or []:
        print(f"  {w.start:.2f}-{w.end:.2f}: {w.word}")

pipeline · processorHF transformers

pipeline("automatic-speech-recognition", model="openai/whisper-large-v3")High-level. Handles preprocessing + post-processing.
chunk_length_s=30Long-form mode. Slides 30s windows.
batch_size=8Batches chunks in parallel on GPU.
return_timestamps=True | "word"Segment or word timestamps in result["chunks"].
generate_kwargs={"language":"en","task":"transcribe"}Pass through to the underlying generate().
WhisperProcessor.from_pretrained("openai/whisper-large-v3")Low-level: feature extractor + tokenizer. Used in custom training.
WhisperForConditionalGeneration.from_pretrained(…)The model class for fine-tuning with Trainer.
torch_dtype=torch.float16, device="cuda"Half precision on GPU.

Worked example

python
from transformers import pipeline
import torch

asr = pipeline(
    "automatic-speech-recognition",
    model="openai/whisper-large-v3",
    torch_dtype=torch.float16,
    device="cuda",
    chunk_length_s=30,                   # long-form support
    batch_size=8,                        # batched chunks
    return_timestamps="word",            # "word" | True (segment) | False
    generate_kwargs={"language": "en", "task": "transcribe"},
)

result = asr("interview.mp3")
print(result["text"])
for chunk in result["chunks"][:5]:
    print(chunk["timestamp"], chunk["text"])

Pure C++ · CPU + Metalwhisper.cpp

./models/download-ggml-model.sh base.enFetch a quantized GGML model into ./models/.
whisper-cli -m models/ggml-base.en.bin -f audio.wavBasic transcribe. Outputs text to stdout.
-l en -trSet language; -tr translates to English.
-osrt, -ovtt, -oj, -ocsvOutput SRT, VTT, JSON, or CSV alongside the text.
-t 8CPU threads. Match physical cores.
-bs 5Beam size. Default is greedy (=1).
-pp / --print-progressProgress bar for long files.
stream -m models/ggml-base.en.binRealtime mic streaming. Separate binary.
--gpu-device 0 / --no-gpuPick or disable Metal / CUDA backend.

Beyond plain textTimestamps, VAD, diarization

Timestamps

segment["start"], segment["end"]Per-segment boundaries (seconds). Default in every runtime.
word_timestamps=TruePer-word timing. Adds words list to each segment.
word["probability"]Decoder confidence (faster-whisper). Filter low scores.
Timestamps drift on long filesUse VAD or chunked decoding to reset; raw Whisper accumulates error.

Voice activity detection

vad_filter=True (faster-whisper)Built-in Silero VAD. Trims silence before inference.
vad_parameters={"threshold":0.5,"min_silence_duration_ms":500}Tune sensitivity + minimum gap.
pyannote/segmentation-3.0External VAD when you want more control or are using openai-whisper.
webrtcvadLightweight CPU VAD. Used in streaming setups.

Diarization (who spoke when)

pyannote.audio — "pyannote/speaker-diarization-3.1"SOTA open-source diarization. Needs a HF token + license accept.
whisperxWraps faster-whisper + pyannote + forced alignment.
align word stamps to diarization spansWhisper does ASR, pyannote does diarization, you merge by time.

Hours of inputLong-form audio

openai-whisper handles long files nativelySliding 30s window. Conditioning on prior text can loop — toggle off if it does.
faster-whisper + vad_filter=TrueRecommended for long content. Skips silence and resets context.
HF pipeline: chunk_length_s=30, stride_length_s=(6, 0)Overlap chunks to recover words split at the boundary.
ffmpeg -i in.mp4 -ar 16000 -ac 1 out.wavAlways 16 kHz mono. Whisper resamples but pre-converting is faster + reproducible.
Initial prompt for context driftPass a short prompt with proper nouns; resets every chunk improves names + acronyms.

Realtime mic inputStreaming

Whisper is not a streaming modelAll open-source streaming is "chunk + re-decode" with overlap.
whisper_streaming (Macháček et al.)Reference research streaming wrapper on openai-whisper.
whisper-live, faster-whisper-serverWebSocket servers that buffer audio + emit partial transcripts.
RealtimeSTTPython lib bundling VAD + faster-whisper for desktop apps.
whisper.cpp `stream` binaryBuilt-in realtime mic transcription. Low resource.
For true low-latency < 300 ms, use distil-whisper or moonshineDifferent architectures designed for streaming.

No local installHosted API

openai.audio.transcriptions.create(model="whisper-1", file=…)Legacy hosted Whisper. 25 MB file cap.
model="gpt-4o-transcribe" | "gpt-4o-mini-transcribe"Preferred OpenAI’s newer ASR models. Better in noisy conditions.
response_format="json" | "verbose_json" | "srt" | "vtt" | "text"Server-side formatting.
timestamp_granularities=["word","segment"]Requires verbose_json.
openai.audio.translations.create(…)Translate non-English audio to English text.

Video → SRT · ~25 linesEnd-to-end · Video → subtitles

faster-whisper handles audio extraction (ffmpeg under the hood), VAD-filters silence, and we write a valid SRT file with segment timestamps.

python
from faster_whisper import WhisperModel
from datetime import timedelta

def fmt(t: float) -> str:
    td = timedelta(seconds=t)
    s = str(td)
    return ("0:" + s if td.seconds < 3600 else s).replace(".", ",")[:11]

model = WhisperModel("medium", device="cuda", compute_type="float16")

segments, info = model.transcribe(
    "lecture.mp4",                    # ffmpeg extracts audio automatically
    vad_filter=True,
    word_timestamps=True,
    initial_prompt="Lecture on retrieval-augmented generation, May 2026.",
)

with open("lecture.srt", "w", encoding="utf-8") as f:
    for i, seg in enumerate(segments, start=1):
        f.write(f"{i}\n")
        f.write(f"{fmt(seg.start)} --> {fmt(seg.end)}\n")
        f.write(seg.text.strip() + "\n\n")

print(f"Wrote subtitles · language: {info.language}")

Best practiceGood to know

Pin language=… when you know it. Language detection runs on the first 30s — on noisy or silent intros it picks wrong, then transcribes the whole file as Welsh. Skip the detection if you can.
Use faster-whisper for production. Same weights, same accuracy, ~4× faster, supports int8 on CPU. The only reason to keep openai-whisper is if you’re reproducing paper numbers exactly.
initial_prompt is for vocabulary, not instructions. Whisper isn’t instruction-tuned. Use a short string of domain terms / acronyms / proper nouns — not "transcribe carefully".

Common trapsWatch out for

Hallucinated repeating text on silence. Whisper invents "thanks for watching" / "subtitles by…" during long pauses. Always run VAD on long-form audio, or set condition_on_previous_text=False.
.en models reject other languages silently. Feed Spanish audio into base.en and you get garbage English. Use the multilingual checkpoint (drop the .en) when input language is not guaranteed.
Word timestamps cost ~30% more compute. They require an extra cross-attention pass per word. Disable when you only need segment-level timing.

Go deeperSee also

Whisper FAQ

What is OpenAI Whisper used for?

Whisper is an open-source speech-to-text model that transcribes and translates audio in 99 languages. It is used for video captions, meeting transcription, podcast search indexing, voice command pipelines, and accessibility tools. The large-v3 checkpoint achieves near-human accuracy on English.

What is the difference between Whisper and faster-whisper?

Both use the same model weights. openai-whisper is the reference PyTorch implementation — easiest to install, slowest to run. faster-whisper wraps the CTranslate2 backend with int8 or fp16 quantization, making it ~4x faster with the same accuracy. Use faster-whisper for production workloads.

How does Whisper handle long audio files?

Whisper has a 30-second context window. For long-form audio, enable VAD filtering (vad_filter=True in faster-whisper) to split on silences, or use the chunk_length_s parameter in the HuggingFace pipeline. The openai-whisper CLI handles long files automatically by splitting them with a sliding window.

Which Whisper model should I use?

large-v3 gives the highest accuracy. large-v3-turbo is ~8x faster with a small quality drop and is the practical default for most production use. medium.en is a good balance for English-only workloads. tiny and base are suitable for real-time on-device use where accuracy is less critical.

Is Whisper free to use?

Yes. The openai-whisper library and all model weights are open source under the MIT license. faster-whisper, whisper.cpp, and the HuggingFace transformers integration are also free. The OpenAI hosted Whisper API is a paid cloud service and is separate from the open-source model.