Skip to main content

combs_media/
lib.rs

1//! # combs-media
2//!
3//! Media preprocessing — the traits-first basic block for non-text
4//! modalities. Vision (SigLIP-style image preprocessing) and audio (WAV →
5//! 16 kHz → Whisper log-mel) are both plain host-side code (no GPU
6//! dependency) producing normalized tensors the runtime hands to the
7//! model's embedding entry points.
8
9mod audio;
10mod images;
11
12pub use audio::{
13    decode_wav, pad_or_trim, resample_linear, LogMel, CHUNK_FRAMES, CHUNK_SAMPLES, HOP_LENGTH,
14    N_FFT, N_MELS, SAMPLE_RATE,
15};
16pub use images::{ImagePreprocessor, PixelBatch, SiglipPreprocessor};
17
18/// Errors produced while decoding or preprocessing media.
19#[derive(Debug, thiserror::Error)]
20pub enum MediaError {
21    /// The payload could not be decoded as an image.
22    #[error("image decode failed: {0}")]
23    Decode(String),
24    /// The payload could not be decoded as audio.
25    #[error("audio decode failed: {0}")]
26    AudioDecode(String),
27    /// The payload had an unsupported or empty shape.
28    #[error("bad media shape: {0}")]
29    BadShape(String),
30}
31
32/// Convenient result alias for this crate.
33pub type Result<T> = std::result::Result<T, MediaError>;