Expand description
Safe, idiomatic Rust bindings for whisper.cpp
This crate provides high-level, safe Rust bindings for whisper.cpp, OpenAI’s Whisper automatic speech recognition (ASR) model implementation in C++.
§Quick Start
use whisper_cpp_plus::{WhisperContext, FullParams, SamplingStrategy};
// Load a Whisper model
let ctx = WhisperContext::new("path/to/model.bin")?;
// Transcribe audio (must be 16kHz mono f32 samples)
let audio = vec![0.0f32; 16000]; // 1 second of silence
let text = ctx.transcribe(&audio)?;
println!("Transcription: {}", text);§Advanced Usage
use whisper_cpp_plus::{WhisperContext, FullParams, SamplingStrategy, TranscriptionParams};
let ctx = WhisperContext::new("path/to/model.bin")?;
let audio = vec![0.0f32; 16000]; // 1 second of audio
// Configure parameters using builder pattern
let params = TranscriptionParams::builder()
.language("en")
.temperature(0.8)
.enable_timestamps()
.build();
// Transcribe with custom parameters
let result = ctx.transcribe_with_params(&audio, params)?;
// Access segments with timestamps
for segment in result.segments {
println!("[{}-{}]: {}", segment.start_seconds(), segment.end_seconds(), segment.text);
}Re-exports§
pub use whisper_cpp_plus_sys;
Modules§
- enhanced
- Enhanced optimizations for whisper-cpp-plus
Structs§
- Async
Whisper Stream - An async streaming transcriber with channels for audio input
- Full
Params - PcmReader
- Threaded PCM reader — direct port of
pcm_async. - PcmReader
Config - Configuration for
PcmReader. - Segment
- Shared
Async Stream - A shared async stream for multiple producers
- Transcription
Params - Transcription
Params Builder - Transcription
Result - VadContext
Params - VAD context parameters
- VadParams
- VAD parameters for speech detection
- VadParams
Builder - Builder for VadParams
- VadSegments
- Speech segments detected by VAD
- Whisper
Context - Whisper
Quantize - Model quantizer for converting Whisper models to different quantization formats
- Whisper
State - Whisper
Stream - Streaming transcriber — faithful port of stream.cpp main loop.
- Whisper
Stream Config - Streaming config — maps to stream.cpp’s whisper_params (streaming subset).
- Whisper
Stream Pcm - Streaming PCM transcriber — direct port of
stream-pcm.cppmain loop. - Whisper
Stream PcmConfig - Configuration for
WhisperStreamPcm— maps towhisper_paramsstreaming subset. - Whisper
VadProcessor - Voice Activity Detector
Enums§
- PcmFormat
- Input PCM sample format.
- Quantization
Type - Quantization types supported by whisper.cpp
- Quantize
Error - Error type for quantization operations
- Sampling
Strategy - Whisper
Error
Functions§
- vad_
simple - Energy-based VAD — port of
common.cpp::vad_simple.