Skip to main content

blazen_audio_stt/
lib.rs

1//! # blazen-audio-stt
2//!
3//! Multi-backend speech-to-text engine crate for Blazen. Sibling to
4//! `blazen-audio-tts`, `blazen-audio-music`, and `blazen-audio-codec`;
5//! all four share the capability-agnostic vocabulary defined in
6//! [`blazen_audio`].
7//!
8//! ## Surface shape
9//!
10//! - [`SttBackend`]: capability trait extending [`blazen_audio::AudioBackend`]
11//!   that every STT engine implements.
12//! - [`SttBackendHandle<B>`]: typed wrapper for Rust callers; monomorphizes
13//!   on the concrete backend.
14//! - [`DynSttProvider`]: erased wrapper (`Box<dyn SttBackend>`) for FFI
15//!   / language-binding boundaries that cannot carry generics. See
16//!   `Appendix B` of the PR-AUDIO plan for the dual-shape rationale.
17//! - [`SttOptions`]: cross-backend options (model id, language hint,
18//!   sample rate, device, diarization toggle).
19//! - [`SttError`]: capability-agnostic error type; flattens engine-native
20//!   failures into one of a small set of variants and implements
21//!   `From<SttError> for blazen_audio::AudioError`.
22//! - [`TranscriptionResult`] / [`TranscriptionSegment`]: result types.
23//! - [`StreamingTranscript`]: per-chunk emission from the streaming
24//!   `SttBackend::stream` surface.
25//!
26//! ## Backends
27//!
28//! Each backend lives in [`backends`] under its own feature gate:
29//!
30//! | Backend     | Feature       | Notes                                          |
31//! |-------------|---------------|------------------------------------------------|
32//! | whisper.cpp | `whispercpp`  | Local CPU/GPU via the `whisper-rs` bindings.   |
33//! | candle      | `candle`      | Pure-Rust Whisper via `candle-transformers`.   |
34//!
35//! Platform-specific acceleration for the whisper.cpp backend (`cuda`,
36//! `metal`, `coreml`) is exposed as opt-in no-op alias features —
37//! consumers wanting GPU acceleration must add `whisper-rs` as a direct
38//! dependency in their binary crate. See this crate's `Cargo.toml`
39//! comments for the rationale.
40
41#![deny(missing_docs)]
42
43pub mod backends;
44pub mod error;
45pub mod options;
46pub mod provider;
47pub mod traits;
48
49pub use error::SttError;
50pub use options::SttOptions;
51pub use provider::{DynSttProvider, SttBackendHandle};
52pub use traits::{StreamingTranscript, SttBackend, TranscriptionResult, TranscriptionSegment};
53
54#[cfg(feature = "candle")]
55pub use backends::candle::{
56    CandleWhisperBackend, CandleWhisperConfig, WhisperModel as CandleWhisperModel, WhisperTask,
57};
58
59#[cfg(feature = "whisper-streaming")]
60pub use backends::whisper_streaming::{WhisperStreamingBackend, WhisperStreamingConfig};
61
62#[cfg(feature = "faster-whisper")]
63pub use backends::faster_whisper::{FasterWhisperBackend, FasterWhisperConfig};