Expand description
Kaldi-style FBANK (log-mel filterbank) feature extraction.
Produces the 80-dim features that the wespeaker speaker-embedding
ONNX model in crate::voice::speaker consumes. Parameters match
sherpa-onnx’s kaldi-native-fbank defaults for that model:
- 16 kHz mono input
- 25 ms window (400 samples) / 10 ms hop (160 samples)
- Pre-emphasis
0.97 - Hamming window
- 80 mel bins, low-freq 20 Hz, high-freq 8000 Hz
- Slaney/Kaldi mel scale:
1127 · ln(1 + f/700) - Log applied to mel energies (
ln(power + 1e-10)) - Cepstral mean normalisation across all frames of the supplied window
The implementation is pure-Rust DSP; the only non-std dep is
rustfft for the 512-point real FFT.
Constants§
- FFT_
SIZE - FFT size: smallest power of two ≥ frame length (400 → 512).
- FRAME_
LENGTH_ MS - Frame length in milliseconds.
- FRAME_
SHIFT_ MS - Frame shift (hop) in milliseconds.
- HIGH_
FREQ_ HZ - Mel-filter high-frequency cutoff (Hz). Half the sample rate.
- LOW_
FREQ_ HZ - Mel-filter low-frequency cutoff (Hz). Kaldi default.
- NUM_
MEL_ BINS - Number of mel bins (also the feature dimension per frame).
- PREEMPHASIS
- Pre-emphasis coefficient — boost high frequencies before windowing.
- SAMPLE_
RATE - Target sample rate: wespeaker is trained on 16 kHz audio.
Functions§
- build_
mel_ filterbank - Builds the triangular mel filterbank as a dense
[num_bins][fft_size/2 + 1]matrix indexed[mel_bin][fft_bin]. - compute_
fbank - Computes 80-dim Kaldi-style FBANK features for the supplied 16 kHz mono floating-point PCM window. Returns one feature row per frame, already cepstral-mean-normalised across the window.