pub enum DataFrame {
InputAudio {
bytes: Arc<[u8]>,
sample_rate: u32,
num_channels: u16,
},
Transcript(Arc<str>),
Audio(AudioChunk),
Custom(Arc<dyn CustomFrame>),
}Expand description
Data frames: media payload flowing downstream (source → sink).
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(Arc<str>)
A text transcript segment (ASR output or TTS input).
Audio(AudioChunk)
A chunk of f32 PCM audio carrying its own AudioFormat.
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.
use std::sync::Arc;
use pipecrab_core::{AudioChunk, AudioFormat, DataFrame};
let input = DataFrame::InputAudio {
bytes: Arc::from(&[0u8; 4][..]),
sample_rate: 16_000,
num_channels: 1,
};
assert!(input.survives_flush());
assert!(!DataFrame::Transcript("hi".into()).survives_flush());
let audio = AudioChunk::new(Arc::from(&[0.0f32][..]), AudioFormat::new(48_000, 1));
assert!(!DataFrame::Audio(audio).survives_flush());Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for DataFrame
impl !UnwindSafe for DataFrame
impl Freeze for DataFrame
impl Send for DataFrame
impl Sync for DataFrame
impl Unpin for DataFrame
impl UnsafeUnpin for DataFrame
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more