pub struct PreprocessingConfig {
pub highpass_cutoff_hz: f32,
pub sample_rate_hz: u32,
pub dc_bias_alpha: f32,
pub enable_dc_removal: bool,
pub enable_highpass: bool,
pub highpass_order: HighpassOrder,
}Expand description
Configuration for DC offset removal and high-pass filtering.
§Examples
use speech_prep::preprocessing::PreprocessingConfig;
// Default: 80 Hz high-pass, 16kHz sample rate, EMA α=0.95
let config = PreprocessingConfig::default();
// Custom configuration for noisy environment
let config = PreprocessingConfig {
highpass_cutoff_hz: 120.0, // More aggressive low-frequency removal
dc_bias_alpha: 0.98, // Slower DC adaptation
..Default::default()
};Fields§
§highpass_cutoff_hz: f32High-pass filter cutoff frequency in Hz.
Range: 60.0 - 120.0 Default: 80.0
Effect: Frequencies below this cutoff are attenuated (≥20 dB at fc/2). Higher cutoffs remove more low-frequency content but may affect speech naturalness.
Recommendation:
- 60-80 Hz: Standard speech (default)
- 80-100 Hz: Noisy environments with HVAC/rumble
- 100-120 Hz: Extreme low-frequency noise
sample_rate_hz: u32Audio sample rate in Hz.
Typical Values: 16000, 44100, 48000 Default: 16000
Effect: Determines filter coefficient calculation. Must match the actual sample rate of input audio.
dc_bias_alpha: f32EMA smoothing factor for DC bias estimation.
Range: 0.9 - 0.99 Default: 0.95
Effect: Controls adaptation speed of DC bias tracking.
- Higher (0.95-0.99): Slower adaptation, smoother (recommended)
- Lower (0.90-0.94): Faster adaptation, less smooth
Formula: bias_new = α × bias_old + (1-α) × sample_mean
enable_dc_removal: boolEnable DC offset removal stage.
Default: true
Effect: When false, DC removal is skipped (filter-only mode). Useful if audio is already DC-free (rare).
enable_highpass: boolEnable high-pass filtering stage.
Default: true
Effect: When false, high-pass filter is skipped (DC-only mode). Useful for testing or if audio already high-pass filtered.
highpass_order: HighpassOrderOrder of the high-pass filter.
Default: FourthOrder (two cascaded biquads)
Effect: Higher order increases low-frequency attenuation at the cost
of additional computation. FourthOrder meets the ≥20 dB @ 40 Hz
target.
Implementations§
Trait Implementations§
Source§impl Clone for PreprocessingConfig
impl Clone for PreprocessingConfig
Source§fn clone(&self) -> PreprocessingConfig
fn clone(&self) -> PreprocessingConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more