mfccFeats method

List<List<double>> mfccFeats (
  1. List<num> signal,
  2. int sampleRate,
  3. int windowLength,
  4. int windowStride,
  5. int fftSize,
  6. int numFilters,
  7. int numCoefs,
  8. {bool energy: true,
  9. double preEmphasis: 0.97}
)

Generates MFCC features from a signal.

  • signal - The signal to extract the features from.
  • sampleRate - The signal sampling rate -sample/s- (> 0).

MFCC are extracted using temporal sliding windows

  • windowLength - Window length in number of samples (> 0 && <= signal.length).
  • windowStride - Window stride in number of sample (> 0)
  • fftSize - Number of fft generated by window (> 0)
  • numFilters - Number of MEL filters (> 0)
  • numCoefs - Number of cepstral coefficient to keep (> 0 && <= numFilters)
  • {energy = true} - If True, replaces the first value by the window log-energy.
  • {preEmphasis = 0.97} - Apply signal preEmphasis. If the value is null, does nothing.

Throws ValueError if any value is off limit.

Implementation

static List<List<double>> mfccFeats(List<num> signal, int sampleRate, int windowLength,
                               int windowStride, int fftSize, int numFilters, int numCoefs, {bool energy = true, double preEmphasis = 0.97}) {
  if (sampleRate <= 0) throw ValueError('Sample rate must be > 0 (Got $sampleRate).');
  if (windowLength <= 0) throw ValueError('Window length must be > 0 (Got $windowLength).');
  if (windowStride <= 0) throw ValueError('Stride must be > 0 (Got $windowStride).');
  if (windowLength > signal.length) throw ValueError('Window length cannot be greater than signal length.(Got $windowLength > ${signal.length})');
  if (numFilters <= 0) throw ValueError('Number of filter must be positive (Got $numFilters).');
  if (numCoefs <= 0) throw ValueError('Number of coefficient must be positive (Got $numCoefs).');
  if (numCoefs > numFilters) throw ValueError('Number of coefficient must be inferior to the number of filters (Got $numCoefs > $numFilters).');

  var frames = splitSignal(signal, windowLength, windowStride);
  var processor = MFCC(sampleRate, fftSize, numFilters, numCoefs, energy: energy, preEmphasis: preEmphasis);
  return processor.process_frames(frames);

}