faster-whisper
Fast, low-memory Whisper speech-to-text transcription powered by CTranslate2.
Repository Health
Technical Analysis
faster-whisper is a reimplementation of OpenAI’s Whisper speech recognition model on top of CTranslate2, a highly optimized inference engine for Transformer models. Swapping the reference PyTorch implementation for CTranslate2 makes transcription up to 4x faster than openai/whisper at the same accuracy, while using significantly less memory — an effect that compounds further with 8-bit quantization on both CPU and GPU.
The library exposes a single WhisperModel class that downloads and runs any Whisper checkpoint (the standard OpenAI sizes, community distil-whisper models, or a custom fine-tune converted to CTranslate2 format) with no FFmpeg system dependency — audio decoding goes through the bundled PyAV library instead. Built-in Silero VAD filtering strips silence before it reaches the model, BatchedInferencePipeline runs multiple audio chunks through the model in parallel for further GPU throughput, and word-level timestamps are available via a forced-alignment pass. It has become a common backend for other projects (WhisperX, WhisperLive, whisper-diarization, speaches) that need fast Whisper inference without touching CTranslate2 or the alignment logic directly.
What You Get
- A
WhisperModelclass that downloads any Whisper size (tiny through large-v3, turbo) or a custom-converted checkpoint from the Hugging Face Hub and runs it on CPU or GPU BatchedInferencePipeline, a drop-in replacement forWhisperModel.transcribethat batches audio chunks for higher GPU throughput- Built-in Silero VAD filtering (
vad_filter=True) to skip non-speech audio before it reaches the model - Word-level timestamps via a forced-alignment pass over the decoded tokens
- 8-bit and float16 quantization options for both CPU and GPU inference (
compute_type="int8","int8_float16", etc.) - Audio decoding through the bundled PyAV/FFmpeg libraries, so no system FFmpeg install is required
Common Use Cases
- Self-hosted transcription services that need OpenAI-Whisper-level accuracy without the GPU memory and latency cost of the reference implementation
- Real-time or near-real-time captioning pipelines built on top of the batched inference API
- Speaker-diarization and alignment pipelines (WhisperX-style) that need fast, word-timestamped Whisper output as an upstream stage
- Podcast, meeting, and video transcription tools that run entirely offline/on-prem
- Backend engine for OpenAI-API-compatible transcription servers
Under The Hood
Architecture
The library centers on a WhisperModel class (in faster_whisper/transcribe.py) that wraps a ctranslate2.models.Whisper instance alongside a Hugging Face tokenizers.Tokenizer and a FeatureExtractor (audio.py/feature_extractor.py). Its transcribe() method drives generate_segments(), which seeks through the audio frame-by-frame, calls generate_with_fallback() for temperature-based decoding retries, _split_segments_by_timestamps() to break decoder output into timed segments, and an optional add_word_timestamps() alignment pass. When VAD filtering is enabled, vad.py’s get_speech_timestamps()/collect_chunks() trims silence before features are even extracted. BatchedInferencePipeline reuses the same WhisperModel but batches multiple audio chunks through generate_segment_batched() for GPU throughput. Supporting modules (audio, feature_extractor, tokenizer, vad) are cleanly separated single-purpose files, but the core orchestration logic is concentrated in one large transcribe.py, so most non-trivial changes to decoding behavior touch that file directly.
Tech Stack
Python 3.9+, built on ctranslate2 (the C++ inference engine that does the actual model execution), huggingface_hub for downloading and caching converted Whisper weights, tokenizers for the Whisper BPE tokenizer, onnxruntime to run the bundled Silero VAD model, and av (PyAV) for FFmpeg-free audio decoding — a deliberate difference from openai/whisper, which shells out to a system FFmpeg binary. Packaged with plain setuptools/setup.py for PyPI distribution. CI (GitHub Actions) runs Black, isort, and Flake8 checks plus pytest on every push and PR.
Code Quality
A real pytest suite exists (tests/test_tokenizer.py, test_transcribe.py, test_utils.py) covering tokenizer behavior, end-to-end transcription, and model-download utilities, and CI enforces formatting/lint/tests on every change. Extensive docstrings (notably WhisperModel.__init__) document parameters in detail. Error handling favors explicit ValueError/assert over silent fallbacks (e.g. invalid model size, negative timestamps). Type hints are used throughout via dataclasses and typing.Optional/Union, though there’s no dedicated static type-checking step in CI, and the core transcription logic is concentrated in one large module rather than split into smaller, independently testable units.
What Makes It Unique The core contribution is swapping Whisper’s reference PyTorch execution for CTranslate2, a purpose-built fast-inference engine, which yields substantially lower latency and memory use — compounded further by CTranslate2’s native int8/float16 quantization rather than relying on generic PyTorch-level optimization. It goes further than a thin CTranslate2 wrapper by integrating Silero VAD filtering directly into the transcription pipeline and implementing its own word-level alignment on top of raw decoder output, rather than leaving those concerns to the caller. The innovation is concentrated in the inference/serving layer rather than the model architecture itself, but it’s a widely adopted foundation — multiple downstream projects (WhisperX, WhisperLive, speaches) build directly on top of it instead of re-solving the same problem.
Used by 3 apps in this directory
Graphify
AI Agents
A YC-backed, open-source knowledge graph skill for AI coding assistants — type /graphify and it maps your entire project (code, docs, PDFs, images, videos) into a queryable graph instead of grepping through files.
Open WebUI
AI Assistants · AI Agents
The extensible, privacy-first AI platform that runs Ollama, OpenAI, and any LLM backend behind a polished, feature-packed web interface.
SurfSense
Search · AI Assistants
The open-source, unlimited NotebookLM alternative with real-time collaboration, a desktop app, and no vendor lock-in.