pub struct AudioInput {
pub source_path: PathBuf,
pub samples: Arc<[f32]>,
pub sample_rate: u32,
pub duration_secs: f64,
}Expand description
In-memory audio ready for a transcription provider.
Fields§
§source_path: PathBufOriginal file path when loaded from disk; synthetic label for PCM (pcm://…).
samples: Arc<[f32]>Mono f32 samples in [-1.0, 1.0], shared to avoid extra copies.
For the local provider this must be WHISPER_SAMPLE_RATE.
sample_rate: u32Sample rate of Self::samples.
duration_secs: f64Duration in seconds.
Implementations§
Source§impl AudioInput
impl AudioInput
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