Speech Representations › Audio Preprocessing Pipeline
Language AI HandbookAll chapters Speech Representations › Audio Preprocessing PipelineOne section · Sections in this chapter4 / 11 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Before computing mel spectrograms, several preprocessing steps condition the signal for analysis. These steps standardize the input, emphasize speech-relevant frequencies, and prepare the signal for spectral analysis. Each step addresses specific physical or perceptual properties of speech production and hearing, forming a principled pipeline that has evolved through decades of speech processing research.
Pre-emphasis
Speech signals have more energy at low frequencies (below 1 kHz) than at high frequencies, due to the physics of vocal fold vibration and vocal tract resonance. As the vocal folds open and close, they create a glottal pulse rich in harmonics, but the spectral envelope naturally rolls off at approximately -6 dB per octave due to the radiation characteristic of the lips and the physical properties of the glottal source. This spectral tilt causes high-frequency consonants (like fricatives) to be relatively weak compared to vowels. If we compute the mel spectrogram without pre-emphasis, the low-frequency vowel energy will dominate and high-frequency consonant information may be too faint for the network to learn from reliably.
Pre-emphasis applies a first-order high-pass filter to compensate:
where:
- : the pre-emphasized signal at sample
- : the input signal at sample
- : the pre-emphasis coefficient (typically 0.97), controlling the degree of high-frequency boost
- : the input signal at the previous sample (delay of one sample)
With , this filter boosts high frequencies by approximately 6 dB per octave, flattening the spectrum and compensating for the natural roll-off of speech. To understand why rather than some other value, consider the z-domain transfer function of this filter: . Its zero is at , very close to the unit circle at low frequencies, meaning the filter has weak attenuation at DC and increasingly strong attenuation as frequency decreases toward zero. The result is a gentle high-pass filter that amplifies high frequencies without introducing audible artifacts.
Pre-emphasis also compensates for the radiation characteristic of the lips, which attenuates low frequencies relative to high frequencies. By equalizing the spectrum, pre-emphasis ensures that high-frequency consonant information (necessary for distinguishing "s" from "sh" or "f" from "v") receives adequate representation in the subsequent spectral analysis.
The effect is reversible through de-emphasis, though in practice recognition systems work entirely in the pre-emphasized domain since the neural network learns to interpret the equalized spectral patterns directly.
Framing and Windowing
Speech analysis proceeds frame-by-frame to respect the quasi-stationarity assumption discussed earlier. Standard parameters include:
- Frame size: 25 milliseconds (400 samples at 16 kHz)
- Frame shift (hop length): 10 milliseconds (160 samples at 16 kHz)
- Overlap: 60% (15 ms of each frame overlaps with neighbors)
This overlap ensures temporal continuity and prevents information loss at frame boundaries. A phoneme transition falling between frame centers will still influence adjacent frames, maintaining acoustic context. The 25ms window provides sufficient duration to resolve frequency details (frequency resolution is inversely proportional to window length) while being short enough to capture rapid phonetic changes.
The relationship between window length and frequency resolution is quantitative. For a window of samples at sampling rate , the frequency resolution is . At 16 kHz with samples (25ms), this gives Hz per frequency bin. Formant frequencies in typical male speech are spaced roughly 1000-1200 Hz apart, meaning our 40 Hz resolution is more than sufficient to separate them. For higher-pitched voices with formants spaced closer together, the 25ms window remains adequate; the basic frequency (100-300 Hz for most speakers) determines the harmonic spacing, and the formant envelope is typically much smoother than individual harmonics.
After extracting each frame, we apply a window function (Hamming or Hann) to taper the signal to zero at the edges. Without windowing, the sharp discontinuities at frame boundaries would introduce spectral artifacts called sidelobes, spreading energy from strong frequencies into other frequency bins and obscuring the true spectral content.
FFT and Power Spectrum
Each windowed frame undergoes Fast Fourier Transform (typically with or points, zero-padded if necessary). Zero-padding interpolates the spectrum. This provides smoother frequency bins without adding actual frequency resolution (which is determined by the actual data length, not the FFT size). We compute the power spectrum by squaring the magnitude of the complex FFT output:
where:
- : the power spectral density at frequency bin
- : the FFT size (number of points in the Fast Fourier Transform)
- : the squared magnitude of the complex FFT output at bin
- : the frequency bin index, ranging from to
For to , the remaining bins are redundant for real signals due to conjugate symmetry. This yields unique frequency bins spanning 0 to Hz. The power spectrum represents the distribution of energy across frequencies for that brief moment in time.
The FFT is computationally efficient due to the Fast Fourier Transform algorithm, which reduces the complexity of computing the Discrete Fourier Transform from to . For typical frame sizes and batch processing, this makes spectrogram computation a small fraction of the total processing time compared to the neural network forward pass.
Complete Pipeline Summary
The full preprocessing pipeline turns raw audio into model-ready features through a sequence of operations that progressively extract and compress perceptually relevant information:
- Pre-emphasis: : Equalizes the spectrum by boosting high frequencies
- Framing: Extract overlapping 25ms frames every 10ms: Segments the signal into quasi-stationary chunks
- Windowing: Apply Hamming window to each frame: Tapers edges to prevent spectral leakage
- FFT: Compute 512-point FFT, extract magnitude: Transforms to frequency domain
- Power spectrum: Square magnitudes: Converts to energy representation
- Mel filtering: Apply 80 triangular mel filters: Aggregates linear frequencies into perceptual bands
- Log compression: Apply natural log with : Matches human loudness perception and compresses dynamic range
The output is a 2D tensor of shape where is the number of time frames (100 per second for 10ms shift) and is the number of mel bins (typically 80). This represents a compression from 16,000 samples per second to 8,000 values per second (100 frames 80 mel bins), a 50-fold reduction in dimensionality while preserving phonetically necessary information.