1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! Audio preprocessing module for clean, analysis-ready audio.
//!
//! This module provides the preprocessing and quality foundation for the crate.
//!
//! # Components
//!
//! - **DC Offset Removal**: Removes DC bias using exponential moving average
//! (EMA)
//! - **High-Pass Filtering**: Attenuates low-frequency rumble (<80 Hz) using
//! Butterworth biquad filters
//! - **Noise Reduction**: Spectral subtraction with adaptive noise profiling
//! (≥6 dB SNR improvement)
//! - **Chunk Continuity**: Maintains filter state across streaming boundaries
//!
//! # Performance
//!
//! - **DC/High-Pass**: <2ms per 500ms chunk (achieved: 0.014-0.127ms)
//! - **Noise Reduction**: <15ms per 500ms chunk (expected: ~7ms)
//! - **Optimization**: Precomputed coefficients, zero-allocation inner loops
//!
//! # Example Pipeline
//!
//! ```rust,no_run
//! use speech_prep::preprocessing::{
//! DcHighPassFilter,
//! NoiseReducer,
//! NoiseReductionConfig,
//! PreprocessingConfig,
//! VadContext,
//! };
//!
//! # fn main() -> speech_prep::error::Result<()> {
//! // Step 1: DC removal + high-pass
//! let dc_config = PreprocessingConfig::default();
//! let mut dc_filter = DcHighPassFilter::new(dc_config)?;
//! let raw_samples = vec![0.0; 8000];
//! let dc_clean = dc_filter.process(&raw_samples, None)?;
//!
//! // Step 2: Noise reduction
//! let noise_config = NoiseReductionConfig::default();
//! let mut noise_reducer = NoiseReducer::new(noise_config)?;
//! let vad_ctx = VadContext { is_silence: false };
//! let denoised = noise_reducer.reduce(&dc_clean, Some(vad_ctx))?;
//! # Ok(())
//! # }
//! ```
pub use ;
pub use ;
pub use Normalizer;
pub use ;