Skip to main content

Analysis

Struct Analysis 

Source
pub struct Analysis { /* private fields */ }
Expand description

Frame values on the original sample timeline, from an Analyzer or external scores.

Frame i stands for original samples [start(i), start(i + 1)), where start(i) = floor(i · hop · sample_rate / frame_rate) in exact integer arithmetic and the last frame ends at the audio length. Thresholds are resolved when segmenting or planning, not here, so one analysis serves any threshold.

Implementations§

Source§

impl Analysis

Source

pub fn from_scores( layout: Layout, len: u64, frames: ScoreFrames, scores: Vec<f32>, ) -> Result<Self, ConfigError>

Wraps per-frame speech probabilities from an external voice activity detector.

len is the length of the original audio in samples per channel. frames.hop is the detector’s hop in samples at frames.sample_rate, which may differ from the original sample rate: a 16 kHz detector with a 512-sample hop maps frame i to original sample floor(i · 512 · sample_rate / 16000). Each frame must span at least one original sample. The scores must cover the audio: the last score starts before len, and less than one hop may be missing at the end.

§Errors

ConfigError::ZeroSampleRate, ConfigError::ZeroChannels, ConfigError::InvalidScoreFrames for a zero rate or hop or a frame shorter than one original sample, ConfigError::InvalidValue for a score outside 0.0..=1.0, or ConfigError::FrameCountMismatch.

Source

pub fn layout(&self) -> Layout

Layout of the original audio.

Source

pub fn sample_count(&self) -> u64

Length of the original audio in samples per channel.

Source§

impl Analysis

Source

pub fn levels(&self, config: &SegmentConfig) -> Option<Levels>

The floor, reference and thresholds used for segmentation, or None when the analysis is empty or every PCM frame is signal-free. Such an analysis is entirely silent.

Source

pub fn segments(&self, config: &SegmentConfig) -> Vec<Span>

Silence and sound spans covering the whole audio in order.

Sound spans include their padding. Two sound spans are adjacent without silence between them when their paddings overlapped.

Source

pub fn trim(&self, config: &SegmentConfig) -> Option<Range<u64>>

The samples from the start of the first sound to the end of the last, padding included, or None if there is no sound.

Trait Implementations§

Source§

impl Clone for Analysis

Source§

fn clone(&self) -> Self

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 Analysis

Source§

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

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

impl<'de> Deserialize<'de> for Analysis

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Analysis

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Analysis

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Analysis

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.