pub struct AudioInput { /* private fields */ }Expand description
In-memory audio ready for a transcription provider.
Fields are private (JOE-1809). Construct with AudioInput::from_pcm /
load_audio, or AudioInput::from_parts_unchecked for trusted internal
decode paths. Prefer accessors over free mutation.
Implementations§
Source§impl AudioInput
impl AudioInput
Sourcepub fn from_parts_unchecked(
source_path: PathBuf,
samples: Arc<[f32]>,
sample_rate: u32,
duration_secs: f64,
) -> Self
pub fn from_parts_unchecked( source_path: PathBuf, samples: Arc<[f32]>, sample_rate: u32, duration_secs: f64, ) -> Self
Trusted construction after decode (no re-validation of every sample).
Prefer from_pcm for host-facing PCM. Callers must
ensure finite samples, positive sample rate, and duration consistency.
pub fn source_path(&self) -> &Path
pub fn samples(&self) -> &Arc<[f32]> ⓘ
pub fn sample_rate(&self) -> u32
pub fn duration_secs(&self) -> f64
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn from_pcm(
samples: impl Into<Arc<[f32]>>,
sample_rate: u32,
) -> Result<Self>
pub fn from_pcm( samples: impl Into<Arc<[f32]>>, sample_rate: u32, ) -> Result<Self>
Build from pre-decoded mono PCM (e.g. mic capture). No ffmpeg, no disk I/O.
sample_rate must be WHISPER_SAMPLE_RATE (16 kHz). Resample upstream if needed.
Sourcepub fn from_pcm_with_limits(
samples: impl Into<Arc<[f32]>>,
sample_rate: u32,
max_duration_secs: f64,
max_decoded_bytes: usize,
) -> Result<Self>
pub fn from_pcm_with_limits( samples: impl Into<Arc<[f32]>>, sample_rate: u32, max_duration_secs: f64, max_decoded_bytes: usize, ) -> Result<Self>
Like from_pcm with explicit safety limits.
Sourcepub fn from_pcm_slice(samples: &[f32], sample_rate: u32) -> Result<Self>
pub fn from_pcm_slice(samples: &[f32], sample_rate: u32) -> Result<Self>
Copy a slice into a new AudioInput (convenience for mic chunks already at 16 kHz).
Trait Implementations§
Source§impl Clone for AudioInput
impl Clone for AudioInput
Source§fn clone(&self) -> AudioInput
fn clone(&self) -> AudioInput
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for AudioInput
impl RefUnwindSafe for AudioInput
impl Send for AudioInput
impl Sync for AudioInput
impl Unpin for AudioInput
impl UnsafeUnpin for AudioInput
impl UnwindSafe for AudioInput
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more