pipecrab_stt/lib.rs
1//! pipecrab-stt: the speech-to-text interface.
2//!
3//! [`StreamingTranscriber`] is the STT capability the conversation pipeline
4//! drives: `f32` audio a window at a time in, [`SttEvent`]s out — partial
5//! hypotheses while the user is still speaking, then a final transcript, which
6//! is what a low-latency conversation loop needs. Concrete models stay behind
7//! it, so the pipeline never names one.
8//!
9//! An engine reaches that interface one of two ways:
10//!
11//! * A native streaming engine (e.g. a streaming Zipformer) implements
12//! [`StreamingTranscriber`] directly, emitting real partials.
13//! * A chunk-final engine (e.g. Moonshine) implements the simpler one-shot
14//! [`Transcriber`] — `f32` samples in, one transcript out, no partials — and
15//! the [`Buffered`] adapter lifts it to [`StreamingTranscriber`] by
16//! accumulating the utterance and transcribing it once at the end. So a
17//! partial-less engine still plugs into the same streaming interface, without
18//! the pipeline knowing the difference.
19//!
20//! [`SttStage`] adapts a [`StreamingTranscriber`] into a pipeline
21//! [`Stage`](pipecrab_runtime::Stage) as a **stateless protocol adapter**.
22//!
23//! # Format authority
24//!
25//! Format authority flows from the party that *knows* the requirement, not from
26//! whatever the wire happens to carry. Stages reject fatally mismatched formats.
27//!
28//! Platform-neutral and `wasm32`-checkable: the concrete engines live elsewhere
29//! (native `ort`, browser Transformers.js in a Web Worker), each behind these
30//! traits, so the interface itself carries no backend dependency and compiles for
31//! both the host and `wasm32-unknown-unknown`.
32#![forbid(unsafe_code)]
33#![warn(missing_docs)]
34
35mod stage;
36mod streaming;
37mod transcriber;
38
39pub use stage::{SttEffect, SttStage};
40pub use streaming::{Buffered, StreamingTranscriber, SttEvent};
41pub use transcriber::{SttError, Transcriber};