CodeVetter
← All unpacks
CodeVetter · Repo Unpack evidence

openai/whisper

Scanned commit 86098128c0 dated 2026-08-31 — last upstream commit. Generated by codevetter 1.12.0 on 2026-09-22.

github.com/openai/whisper ↗ · 42 files · 2.2 MB

Whisper [[Blog]](https://openai.com/blog/whisper) [[Paper]](https://arxiv.org/abs/2212.04356) [[Model card]](https://github.com/openai/whisper/blob/main/model-card.md) [[Colab example]](https://colab.research.google.com/github/openai/whisper/blob/master/notebo

Deep analysis by swe-2 via the devin CLI on 2026-09-22 (runtime not recorded) — every claim below links to its cited source files.

Overview

OpenAI Whisper is a general-purpose speech-recognition library (Python + PyTorch) that ships both a `whisper` CLI and an importable `whisper` package. It downloads pretrained encoder-decoder Transformer checkpoints (tiny through large-v3-turbo) from OpenAI's CDN with SHA256 verification, decodes arbitrary audio to 16 kHz mono via an ffmpeg subprocess, converts it to log-Mel spectrograms, and runs an autoregressive seq2seq decoder over 30-second sliding windows. A single multitask model performs multilingual transcription, X→English translation, language identification, and (via cross-attention DTW) word-level timestamp alignment, emitting results as txt/vtt/srt/tsv/json/jsonl.

System map

The repo is a single flat Python package, `whisper/`, plus a `tests/` pytest suite, GitHub Actions CI, and evaluation docs/notebooks. The CLI entrypoint `whisper.transcribe:cli` (also reachable via `python -m whisper`) parses ~30 argparse options, loads a checkpoint through `load_model` in `whisper/__init__.py`, and runs `transcribe()`. Checkpoints are runtime downloads from openaipublic.azureedge.net, verified by a SHA256 embedded in the URL and cached under ~/.cache/whisper. The model itself is a standard Transformer encoder/decoder defined in model.py; decoding.py implements the sampling engine (greedy/beam, logit filters, KV-cache hooks); audio.py, tokenizer.py, timing.py, utils.py, and triton_ops.py cover the audio pipeline, BPE vocab, DTW alignment, output writers, and optional CUDA kernels respectively.

Feature catalog

User-facing surface is (a) the `whisper` CLI, (b) the Python API (load_model, transcribe, decode, detect_language), and (c) six output formats. Core capabilities: multilingual transcription across 99 languages, X→English translation, automatic language detection, word-level timestamps via attention-based DTW, clip selection, prompt conditioning, and two search strategies (greedy/best-of-N vs beam search). Auxiliary features include text normalizers for evaluation and a hallucination-silence skip heuristic.

All 13 feature catalog claims →

Data flow

Audio enters as a file path (decoded by an ffmpeg subprocess to 16 kHz mono float32) or a NumPy/Torch waveform, then becomes a log-Mel spectrogram (80 or 128 bins, STFT n_fft=400 hop=160) padded with 30 s of silence. The mel tensor feeds AudioEncoder once per 30 s window; DecodingTask autoregressively produces tokens under logit filters and a KV cache, with timestamp tokens (>=tokenizer.timestamp_begin, 0.02 s each) delimiting segments. Segments accumulate in all_segments/all_tokens; optional word-level alignment runs a second decoder pass capturing cross-attention weights through forward hooks. The final dict {text, segments, language} returns to the caller and is serialized by ResultWriter subclasses into output_dir.

Behavior traces

Three end-to-end flows were traced. (1) CLI startup: cli() → argparse → load_model → per-file transcribe → writer. (2) Model loading: name → _MODELS URL or local path → _download with SHA256 → torch.load → Whisper(dims) → set_alignment_heads. (3) Transcription: mel → language detect → per-window decode_with_fallback → DecodingTask.run (encoder → language → _main_loop → finalize → rank) → timestamp segmentation → optional word-level DTW alignment → result dict → file writers.

Testing signals

Tests use pytest in tests/ (5 modules + conftest registering a `requires_cuda` marker and a `random` seed fixture). Coverage is good for the numeric utilities (dtw, median_filter vs scipy), normalizers (extensive assertions), and tokenizer edge cases, plus one end-to-end transcription test parametrized over all 13 model checkpoints against tests/jfk.flac. Major gaps: no coverage of the CLI, output writers, beam search, logit filters, model download, or the transcribe seek-loop heuristics. CI runs pre-commit (black/isort/flake8) and a 9-cell Python×PyTorch matrix on CPU-only torch wheels.

Risk map

Highest-risk areas are (1) the `transcribe()` seek loop — a deliberately flattened, heuristic-heavy control flow the authors flag as obscure; (2) runtime code paths that execute or load external artifacts (ffmpeg subprocess, torch.load of checkpoint files, Triton JIT source patching); and (3) fragile fallbacks — numba JIT at import, the missing `regex` dependency, and silent error swallowing in the CLI. There is also a real latent bug in `_get_audio_features` returning a TypeError object instead of raising it.

Extension points

Extension is mostly class-substitution rather than plugin registration: the get_writer() dict is a mini-registry for output formats; TokenDecoder, LogitFilter, SequenceRanker, and Inference are abstract seams inside DecodingTask; new checkpoints plug in via _MODELS/_ALIGNMENT_HEADS or by path; DecodingOptions is the frozen config dataclass every knob flows through. There is no dynamic plugin discovery — all seams require editing source.

Contributor handoff

Small, flat, readable codebase (~3.7k LOC of Python). Before editing, read whisper/transcribe.py (orchestrator+CLI), whisper/decoding.py (engine), and whisper/model.py (nn defs). Style is enforced by pre-commit (black/isort/flake8) in CI. Tests need ffmpeg and network for model downloads; the fastest local check is `pytest -k 'not test_transcribe'`. Known traps: a return-instead-of-raise bug in _get_audio_features, an undeclared `regex` dependency, Whisper binding free functions as class attributes, and the deliberately convoluted seek loop in transcribe().

Languages

LanguageFilesShare of source
Python2095%
Markdown4docs/config
YAML4docs/config
JSON2docs/config
TOML15%

Start reading here

Probable source entrypoint: pyproject.toml — inferred from the directory tree and manifest, not the upstream docs.

Source roots

whisper/ (18 files)

Source layout — whisper/

PathFiles
whisper/assets/3
whisper/normalizers/4
whisper/__init__.py1
whisper/__main__.py1
whisper/audio.py1
whisper/decoding.py1
whisper/model.py1
whisper/timing.py1
whisper/tokenizer.py1
whisper/transcribe.py1
whisper/triton_ops.py1
whisper/utils.py1
whisper/version.py1

Repository structure

Top-level pathFiles
whisper/18
tests/6
.github/3
data/2
notebooks/1

Docs found: README.md

Package

pyproject.toml — false v{ attr = "whisper.version.__version__" }, 0 declared dependencies.

CI & config entrypoints

Structural health signals

Average score 7.5/10 across 14 analyzed source files; 3 hotspots surfaced.

These are deterministic review leads — size, churn, and structural signals — not proof of a bug in this project.

Recent history