weirdnet-media 0.2.0

Weirdnet media processing for clients and nodes: WAV probing and PCM in pure Rust, 16 kHz resampling, silence-aware chunking, long-audio transcription plans, long-text speech plans, SRT/VTT, video frame planning, and a hardened ffmpeg runner with a test fake.
Documentation
/// Why a waveform operation failed.
#[derive(Debug, Clone, PartialEq)]
pub enum WaveformError {
    ZeroSampleRate,
    ZeroChannels,
    /// The sample count is not a whole number of frames.
    UnalignedSamples {
        samples: usize,
        channels: u16,
    },
    /// A parameter is NaN or infinite.
    NotFinite(&'static str),
    /// A parameter is outside its allowed range.
    OutOfRange {
        what: &'static str,
        min: f64,
        max: f64,
        got: f64,
    },
    /// The operation needs a different channel count (for example pan needs stereo).
    UnsupportedChannels {
        operation: &'static str,
        channels: u16,
    },
    /// Two waveforms have different sample rates or channel counts.
    FormatMismatch,
    /// A mix would be longer than the limit.
    TooLong {
        max_frames: usize,
    },
    /// The bytes are not a WAV this crate reads.
    Wav(String),
}

impl std::fmt::Display for WaveformError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            WaveformError::ZeroSampleRate => write!(f, "the sample rate must be above zero"),
            WaveformError::ZeroChannels => write!(f, "the channel count must be above zero"),
            WaveformError::UnalignedSamples { samples, channels } => {
                write!(f, "{samples} samples is not a whole number of {channels}-channel frames")
            }
            WaveformError::NotFinite(what) => write!(f, "{what} is not a finite number"),
            WaveformError::OutOfRange { what, min, max, got } => write!(f, "{what} must be between {min} and {max}, got {got}"),
            WaveformError::UnsupportedChannels { operation, channels } => {
                write!(f, "{operation} does not work on a {channels}-channel waveform")
            }
            WaveformError::FormatMismatch => write!(f, "the waveforms differ in sample rate or channel count"),
            WaveformError::TooLong { max_frames } => write!(f, "the result would be longer than {max_frames} frames"),
            WaveformError::Wav(why) => write!(f, "not a readable WAV: {why}"),
        }
    }
}

impl std::error::Error for WaveformError {}