pub fn mfcc(
samples: &NonEmptySlice<f64>,
stft_params: &StftParams,
sample_rate: f64,
n_mels: NonZeroUsize,
mfcc_params: &MfccParams,
) -> SpectrogramResult<Mfcc>Expand description
Compute MFCCs directly from audio samples.
This is a convenience function that computes a mel spectrogram, converts to log scale, and extracts MFCC features in a single call.
§Arguments
samples- Audio samples (any type that can be converted to a slice)stft_params- STFT parameterssample_rate- Sample rate in Hzn_mels- Number of mel bandsmfcc_params- MFCC computation parameters
§Returns
An Mfcc structure containing the coefficients.
§Errors
Returns an error if any step of the computation fails.
§Examples
use spectrograms::*;
use non_empty_slice::non_empty_vec;
let samples = non_empty_vec![0.0; nzu!(16000)];
let stft = StftParams::new(nzu!(512), nzu!(160), WindowType::Hanning, true)?;
let mfcc_params = MfccParams::speech_standard();
let mfccs = mfcc(&samples, &stft, 16000.0, nzu!(40), &mfcc_params)?;
assert_eq!(mfccs.n_coefficients(), nzu!(13));
println!("MFCCs: {} coefficients x {} frames",
mfccs.n_coefficients(), mfccs.n_frames());