pipecrab_tts/lib.rs
1//! pipecrab-tts: the text-to-speech interface.
2//!
3//! [`Synthesizer`] is the swappable TTS capability the conversation loop drives:
4//! text in, audio out *incrementally* — every stream item is a preemption point,
5//! so a barge-in [`Interrupt`](pipecrab_core::SystemFrame::Interrupt) can stop
6//! playback within a single chunk. Concrete engines stay behind it, so the
7//! pipeline never names one.
8//!
9//! [`TtsStage`] adapts any [`Synthesizer`] into a pipeline
10//! [`Stage`](pipecrab_runtime::Stage): on a final agent
11//! [`Transcript`](pipecrab_core::Transcript) it synthesizes the text and streams
12//! [`Audio`](pipecrab_core::DataFrame::Audio) chunks in its place; every other
13//! frame passes through untouched.
14//!
15//! [`SentenceChunker`] is the low-latency feeder that sits *upstream* of
16//! [`TtsStage`]: it splits a streaming agent generation into one final agent
17//! [`Transcript`](pipecrab_core::Transcript) per sentence, so synthesis of the
18//! first sentence can begin before the model has finished the last. This is why
19//! a [`Final`](pipecrab_core::Finality::Final) agent transcript is documented as
20//! a *generation* unit that may in practice be a single sentence.
21//!
22//! Platform-neutral and `wasm32`-checkable: the concrete engines live elsewhere
23//! (a native engine, a browser engine in a Web Worker), each behind these
24//! traits, so the interface itself carries no backend dependency and compiles for
25//! both the host and `wasm32-unknown-unknown`.
26#![forbid(unsafe_code)]
27#![warn(missing_docs)]
28
29mod chunker;
30mod stage;
31mod synthesizer;
32
33pub use chunker::{EmitSentence, SentenceChunker};
34pub use stage::{Speak, TtsStage};
35pub use synthesizer::{Synthesizer, TtsAudioStream, TtsError};