pub enum DataFrame {
InputAudio {
bytes: Arc<[u8]>,
sample_rate: u32,
num_channels: u16,
},
Transcript(Transcript),
Audio(AudioChunk),
SpeechStarted,
SpeechStopped,
Custom(Arc<dyn CustomFrame>),
}Expand description
Data frames: everything flowing downstream (source → sink) in FIFO order — the media payload plus the in-band voice-activity edges that must stay ordered with it.
Immutable: don’t try to make mutable frames. Instead, aggregate frames and produce a new one when you’re ready.
Variants§
InputAudio
Input audio from a transport source. Survives an interrupt flush so that
a barge-in utterance is not clipped; see DataFrame::survives_flush.
Fields
Transcript(Transcript)
A piece of conversation text: STT output, LM output, or text bound for
TTS. See Transcript for the role and finality it carries.
Audio(AudioChunk)
A chunk of f32 PCM audio carrying its own AudioFormat.
SpeechStarted
Voice-activity detection observed the user start speaking: the
silence→speech edge, emitted by the VAD stage at onset and followed by the
utterance’s Audio frames.
SpeechStopped
Voice-activity detection observed the user stop speaking: the
speech→silence edge, emitted by the VAD stage after the utterance’s last
Audio frame.
Custom(Arc<dyn CustomFrame>)
Application-defined payload; see CustomFrame.
Implementations§
Source§impl DataFrame
impl DataFrame
Sourcepub fn survives_flush(&self) -> bool
pub fn survives_flush(&self) -> bool
True for frames that must survive an interrupt’s data-queue flush — input-from-transport media, since a barge-in utterance must not be clipped. False for everything else, including the voice-activity edges: like a transcript they are derived control, so a barge-in drops any queued one and fresh edges are regenerated from the surviving transport audio.
use std::sync::Arc;
use pipecrab_core::{AudioChunk, AudioFormat, DataFrame, Transcript};
let input = DataFrame::InputAudio {
bytes: Arc::from(&[0u8; 4][..]),
sample_rate: 16_000,
num_channels: 1,
};
assert!(input.survives_flush());
assert!(!DataFrame::from(Transcript::agent_final("hi")).survives_flush());
let audio = AudioChunk::new(Arc::from(&[0.0f32][..]), AudioFormat::new(48_000, 1));
assert!(!DataFrame::Audio(audio).survives_flush());Trait Implementations§
Source§impl From<Transcript> for DataFrame
impl From<Transcript> for DataFrame
Source§fn from(transcript: Transcript) -> Self
fn from(transcript: Transcript) -> Self
Wrap a Transcript as a DataFrame::Transcript so a stage can write
Transcript::user_final(text).into() instead of naming the variant.