whisper-rs
Safe Rust bindings to whisper.cpp for running OpenAI's Whisper speech-to-text model locally.
Repository Health
Technical Analysis
whisper-rs wraps whisper.cpp (the widely-used C/C++ port of OpenAI’s Whisper speech-recognition model) in a safe Rust API. WhisperContext loads a GGML/GGUF Whisper model file, WhisperState runs inference over a buffer of 32-bit float, 16kHz mono audio samples via FullParams/SamplingStrategy, and the resulting transcript is retrieved segment-by-segment with start/end timestamps. Because it binds directly to whisper.cpp, transcription runs fully on-device with no API calls or per-request cost.
The crate is split into whisper-rs (the safe wrapper) and whisper-rs-sys (the raw FFI bindings and vendored whisper.cpp build, generated via build.rs), and exposes Cargo features to enable GPU acceleration backends — CUDA, HIP/ROCm, Metal, Vulkan, Intel SYCL, CoreML, and OpenBLAS/OpenMP — so the same API can run on CPU or hardware-accelerated depending on the target platform. Development of the project has moved from GitHub to Codeberg (the maintainer’s stated reason being opposition to GitHub’s AI-related product changes); this GitHub repository is the last-synced mirror of the source and remains fully functional and buildable, though new releases and issues are tracked on Codeberg going forward.
What You Get
WhisperContext/WhisperStateAPI for loading a Whisper model and running transcription over raw audio samples- Segment-level transcript output with per-segment start/end timestamps via
full_get_segment_text/full_get_segment_t0/t1 FullParams/SamplingStrategyfor configuring decoding strategy (greedy, beam search) and other inference options- Optional GPU acceleration features:
cuda,hipblas,metal,vulkan,coreml,openblas,openmp,intel-sycl - A separate
whisper-rs-syscrate handling the raw FFI bindings and vendored whisper.cpp build viabuild.rs
Common Use Cases
- Adding fully local, offline speech-to-text transcription to a Rust application without calling a cloud API
- Building voice-command or dictation features that need low-latency, on-device inference
- Batch-transcribing audio/video files (podcasts, meetings, recordings) as part of a Rust media-processing pipeline
- Running Whisper inference on GPU-accelerated hardware (NVIDIA/AMD/Apple Silicon) from a Rust service
Under The Hood
Architecture - The crate is a thin, safe Rust layer (src/, ~3,400 lines) over the whisper-rs-sys FFI crate, which vendors and builds whisper.cpp itself via build.rs/BUILDING.md. WhisperContext::new_with_params loads a model file and constructs the underlying whisper.cpp context; WhisperState::full() runs inference and stores results that are then read out segment-by-segment through safe accessor methods, avoiding manual pointer/lifetime handling for the caller.
Tech Stack - Rust, with the sys sub-crate compiling vendored C/C++ whisper.cpp source at build time; optional dependencies (log, tracing, libc) are feature-gated, and GPU backends (CUDA, HIP, Metal, Vulkan, Intel SYCL, CoreML, OpenBLAS/OpenMP) are opt-in Cargo features that pull in the corresponding whisper.cpp build configuration.
Code Quality - examples/basic_use.rs and examples/audio_transcription.rs provide runnable end-to-end usage, and a test-with-tiny-model feature gates integration tests against a small Whisper model so CI doesn’t need a full-size model file; the project keeps a CHANGELOG.md and BUILDING.md documenting platform-specific build requirements for the various acceleration backends.
API Design - The WhisperContext → WhisperState → full() → segment-accessor flow closely mirrors whisper.cpp’s own C API shape, so users familiar with whisper.cpp need little re-learning, while Rust’s Result-based error handling replaces whisper.cpp’s raw status codes; the raw-api feature exposes lower-level access for callers who need to bypass the safe wrapper.
Used by 2 apps in this directory
Cap
Team Chat · Video Conferencing
Open source Loom alternative with GPU-accelerated recording, instant share links, AI summaries, and full self-hosting via Docker Compose.
Spacedrive
File Storage · Collaboration
One file manager for all your devices and clouds — powered by a Virtual Distributed File System built in Rust.