MFCC
Mel-frequency cepstral coefficients: the orthonormal DCT-II of the dB
mel spectrogram, the compact per-frame
descriptor of classic speech front ends (slaney filterbank, top_db clamp,
optional sinusoidal lifter). The mel stage runs the fused kernel; the DCT is
a small matrix product over the mel axis.
specux.mfcc(x, *, sr, n_mfcc=20, n_fft=2048, hop_length=None, win_length=None, window="hann", center=True, n_mels=128, fmin=0.0, fmax=None, mel_scale="slaney", norm="slaney", lifter=0.0, top_db=80.0, eps=1e-10, backend="auto")import numpy as np
import specux
x = np.random.randn(2, 32768).astype(np.float32)C = specux.mfcc(x, sr=22050, n_mfcc=20)C.shape # (2, 20, 65) = (..., n_mfcc, n_frames)import torch
import specux
xt = torch.randn(2, 32768, device="cuda", requires_grad=True)C = specux.mfcc(xt, sr=22050, n_mfcc=20)C.sum().backward() # differentiable end to endimport cupy
import specux
xc = cupy.random.standard_normal((2, 32768), dtype=cupy.float32)C = specux.mfcc(xc, sr=22050, n_mfcc=20)Parameters beyond the mel spectrogram
n_mfcc: coefficients kept (first rows of the DCT), at mostn_mels.lifter: sinusoidal liftering parameter, weighting coefficientkby1 + (lifter/2) sin(pi k / lifter); 0 disables.top_db: clamp the dB spectrogram atmax - top_dbper item before the DCT;Nonedisables. Defaults to 80.
The remaining parameters pass through to
melspectrogram. For float16 inputs the DCT
and lifter stages compute in float32 (they accumulate over the full mel
axis) and the result is cast back to float16.
The configured form
t = specux.MFCC(sr=22050, n_mfcc=13)C = t(x) # (..., n_mfcc, n_frames)assert specux.MFCC(**t.to_dict()) == tReferences
Mel scale [stevens1937], slaney filterbank [slaney1998]; see References.