Skip to main content

DataFrame

Enum DataFrame 

Source
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

§bytes: Arc<[u8]>

Raw PCM bytes.

§sample_rate: u32

Samples per second (e.g. 16 000 for 16 kHz).

§num_channels: u16

Number of audio channels (1 = mono, 2 = stereo).

§

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

Source

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 Clone for DataFrame

Source§

fn clone(&self) -> DataFrame

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DataFrame

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Transcript> for DataFrame

Source§

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.