pub struct ProcessedChunk {
pub samples: Vec<f32>,
pub start_boundary: ChunkBoundary,
pub end_boundary: ChunkBoundary,
pub start_time: AudioTimestamp,
pub end_time: AudioTimestamp,
pub speech_ratio: f32,
pub energy: f32,
pub snr_db: Option<f32>,
pub has_clipping: bool,
pub overlap_prev: Option<Vec<f32>>,
pub overlap_next: Option<Vec<f32>>,
pub overlap_ms: u32,
}Expand description
A processed audio chunk with temporal and quality metadata.
Represents a segment of audio aligned to speech boundaries.
Fields§
§samples: Vec<f32>Audio samples in the chunk (normalized f32, range [-1.0, 1.0]).
start_boundary: ChunkBoundaryType of boundary at chunk start.
end_boundary: ChunkBoundaryType of boundary at chunk end.
start_time: AudioTimestampAbsolute start time of chunk in audio stream.
end_time: AudioTimestampAbsolute end time of chunk in audio stream.
speech_ratio: f32Ratio of speech frames in chunk (0.0 = all silence, 1.0 = all speech).
Derived from VAD analysis.
energy: f32RMS energy of the chunk (computed during generation).
Useful for quality assessment and thresholding.
snr_db: Option<f32>Signal-to-noise ratio in decibels (dB).
Computed as 20 * log10(signal_rms / noise_rms), where noise_rms is
estimated from silence regions. None if no noise baseline is available
(e.g., first chunk with no silence).
Higher SNR values indicate cleaner audio:
-
30 dB: Excellent quality
- 20-30 dB: Good quality
- 10-20 dB: Acceptable quality
- <10 dB: Poor quality (high noise)
has_clipping: boolIndicates whether the chunk contains clipping artifacts.
Clipping occurs when sample values exceed the normalized range [-1.0, 1.0], typically manifesting as |sample| >= 0.999. Clipped audio may cause audible distortion.
true if any sample in the chunk is clipped, false otherwise.
overlap_prev: Option<Vec<f32>>Overlap samples from the previous chunk (for context).
Contains the trailing overlap_duration samples from the previous
chunk, preserving acoustic context across the boundary.
None for the first chunk in the stream.
overlap_next: Option<Vec<f32>>Overlap samples for the next chunk (for context).
Contains the trailing overlap_duration samples from this chunk, to be
prepended to the next chunk for context. None for the last chunk in
the stream.
overlap_ms: u32Actual overlap duration in milliseconds.
The duration of samples in overlap_prev and overlap_next. Typically
matches ChunkerConfig::overlap_duration (default 50ms), but may be
shorter for chunks at stream boundaries.
Implementations§
Source§impl ProcessedChunk
impl ProcessedChunk
Sourcepub fn duration(&self) -> Result<AudioDuration>
pub fn duration(&self) -> Result<AudioDuration>
Get the duration of this chunk.
§Errors
Returns Error::Processing if end_time < start_time (indicates
invalid chunk).
Sourcepub fn is_silence(&self) -> bool
pub fn is_silence(&self) -> bool
Check if this chunk is silence.
Sourcepub fn samples_without_overlap(&self) -> &[f32]
pub fn samples_without_overlap(&self) -> &[f32]
Get samples without overlap (deduplicated core content).
Returns the chunk’s primary samples, excluding any overlap regions that would be duplicated when processing sequential chunks. Useful for callers that want to avoid processing overlap regions twice.
Sourcepub fn total_samples_with_overlap(&self) -> usize
pub fn total_samples_with_overlap(&self) -> usize
Returns total sample count including overlap regions.
Useful for buffer allocation when reconstructing the full audio data with prepended/appended overlaps.
Trait Implementations§
Source§impl Clone for ProcessedChunk
impl Clone for ProcessedChunk
Source§fn clone(&self) -> ProcessedChunk
fn clone(&self) -> ProcessedChunk
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more