Crate sevensense_audio

Crate sevensense_audio 

Source
Expand description

§sevensense-audio

Audio processing and segmentation for the 7sense bioacoustics platform.

This crate provides:

  • Audio file decoding (WAV, FLAC, MP3, Ogg)
  • Sample rate conversion and normalization
  • Spectrogram generation
  • Segment detection and extraction
  • Audio quality analysis

§Architecture

The crate follows Domain-Driven Design with clean architecture:

  • Domain Layer: Core entities (Recording, CallSegment) and repository traits
  • Application Layer: Use cases and services (AudioIngestionService)
  • Infrastructure Layer: Technical implementations (file readers, resamplers)

§Example Usage

use sevensense_audio::application::AudioIngestionService;
use sevensense_audio::infrastructure::{SymphoniaFileReader, RubatoResampler, EnergySegmenter};
use std::path::Path;
use std::sync::Arc;

// Create infrastructure components
let reader = Arc::new(SymphoniaFileReader::new());
let resampler = Arc::new(RubatoResampler::new(32000)?);
let segmenter = Arc::new(EnergySegmenter::default());

// Create the service
let service = AudioIngestionService::new(reader, resampler, segmenter);

// Ingest an audio file
let mut recording = service.ingest_file(Path::new("recording.wav")).await?;

// Segment the recording to find calls
let segments = service.segment_recording(&mut recording).await?;
println!("Found {} call segments", segments.len());

Re-exports§

pub use domain::entities::Recording;
pub use domain::entities::CallSegment;
pub use domain::entities::SignalQuality;
pub use domain::repository::RecordingRepository;
pub use application::services::AudioIngestionService;
pub use application::error::AudioError;
pub use application::error::AudioResult;
pub use spectrogram::MelSpectrogram;
pub use spectrogram::SpectrogramConfig;

Modules§

application
Application layer for the audio ingestion bounded context.
domain
Domain layer for the audio ingestion bounded context.
infrastructure
Infrastructure layer for the audio bounded context.
spectrogram
Mel spectrogram computation for audio feature extraction.

Constants§

STANDARD_SEGMENT_DURATION_MS
Standard segment duration for analysis (5 seconds).
TARGET_SAMPLE_RATE
Standard target sample rate for all processing (32 kHz).
VERSION
Crate version information.