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
impl Analysis
Sourcepub fn from_scores(
layout: Layout,
len: u64,
frames: ScoreFrames,
scores: Vec<f32>,
) -> Result<Self, ConfigError>
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.
Sourcepub fn sample_count(&self) -> u64
pub fn sample_count(&self) -> u64
Length of the original audio in samples per channel.
Source§impl Analysis
impl Analysis
Sourcepub fn levels(&self, config: &SegmentConfig) -> Option<Levels>
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.
Sourcepub fn segments(&self, config: &SegmentConfig) -> Vec<Span>
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.