1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! Reusable STT core.
//!
//! Every speech-to-text backend in this crate is the same program with a
//! different wire format. The core owns the program; a provider supplies the
//! wire format.
//!
//! ```text
//! ┌─────────────────── SttService<P> ───────────────────┐
//! InputAudioRaw ─┤ AudioFrontend → TurnGate → P::encode_audio → socket │
//! │ ▲ │ │
//! Transcription ─┤ P::parse ── SttEvent ────────────────────────┘ │
//! └────────────────────────────────────────────────────┘
//! ```
//!
//! - [`SttProvider`] — the base trait a service implements: handshake, audio
//! framing, finalize message, and message parsing. Nothing else.
//! - [`SttService`] — generic over `SttProvider`, and the only
//! [`FrameHandler`](crate::frames::FrameHandler) in the STT subsystem. Owns
//! the WebSocket tasks, the turn gate, the audio front-end and billing.
//! - [`TurnGate`] — audio gating, pre-roll, stashed VAD stop, duration ledger.
//! Guarantees the transcript-before-stop ordering that
//! [`LLMUserAggregator`](crate::processors::llm_user_aggregator::LLMUserAggregator)
//! depends on.
//! - [`AudioFrontend`] — resample → high-pass → denoise → AGC + limiter.
//!
//! ## Adding a provider
//!
//! ```ignore
//! struct MyProvider { cfg: MyConfig }
//!
//! impl SttProvider for MyProvider {
//! fn name(&self) -> &'static str { "myprovider" }
//! fn audio(&self) -> &AudioSpec { &self.cfg.audio }
//! fn handshake(&self) -> Handshake {
//! Handshake::new(self.cfg.url()).header("Authorization", &self.cfg.key)
//! }
//! fn encode_audio(&self, pcm_le: &[u8]) -> Outgoing {
//! Outgoing::Binary(pcm_le.to_vec())
//! }
//! fn finalize_msg(&self) -> Option<Outgoing> {
//! Some(Outgoing::Text(r#"{"type":"Finalize"}"#.into()))
//! }
//! fn parse(&self, msg: WsMessage<'_>) -> SttEvent { /* … */ }
//! }
//!
//! let stt = SttService::new(MyProvider { cfg }, SttCoreConfig::default())
//! .into_processor();
//! ```
//!
//! See `services/stt/sarvam.rs` for the worked example.
pub use ;
pub use ;
pub use ;
pub use ;