whisper-rs

Safe Rust bindings to whisper.cpp for running OpenAI's Whisper speech-to-text model locally.

Library
Cargo
v0.16.0
944stars
Unlicense

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
38/100Needs Attention
Development Activity0
Maintenance0
Community60
Maturity52
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
64/100Good
Architecture68
Code Quality62
Innovation65
Learning Curve60

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/WhisperState API 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/SamplingStrategy for 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-sys crate handling the raw FFI bindings and vendored whisper.cpp build via build.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 WhisperContextWhisperStatefull() → 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.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search