kothok_edge_tts/event.rs
1//! Streaming events emitted during a single synthesis turn.
2
3/// One item in the event stream produced by [`crate::Engine::synthesize`].
4///
5/// Events arrive in order. A well-formed turn starts with zero or more
6/// [`Audio`](TtsEvent::Audio) / [`WordBoundary`](TtsEvent::WordBoundary)
7/// events and terminates with exactly one [`TurnEnd`](TtsEvent::TurnEnd).
8#[derive(Debug, Clone)]
9pub enum TtsEvent {
10 /// A chunk of raw MP3 audio bytes (`audio-24khz-48kbitrate-mono-mp3`).
11 /// Concatenate all `Audio` events in order to reconstruct the full
12 /// utterance.
13 Audio(Vec<u8>),
14
15 /// Word-boundary timing metadata for highlight / karaoke effects.
16 /// `offset` and `duration` are in **100-nanosecond ticks** relative to
17 /// the start of the audio stream.
18 WordBoundary {
19 offset: u64,
20 duration: u64,
21 text: String,
22 },
23
24 /// The server signalled `turn.end` - no more audio or metadata will
25 /// arrive for this request.
26 TurnEnd,
27}