Skip to main content

Module features

Module features 

Source
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.