Skip to content

LFCC

Linear-frequency cepstral coefficients: the orthonormal DCT-II of the dB spectrogram under an unnormalized linear triangular filterbank. Common in speaker verification and anti-spoofing work, where the linear scale keeps high-frequency detail the mel scale compresses; the mel-scaled counterpart is MFCC.

specux.lfcc(x, *, sr, n_lfcc=20, n_filter=128, n_fft=2048, hop_length=None,
win_length=None, window="hann", center=True, fmin=0.0, fmax=None,
lifter=0.0, top_db=None, eps=1e-10, backend="auto")
import numpy as np
import specux
x = np.random.randn(2, 32768).astype(np.float32)
C = specux.lfcc(x, sr=16000, n_lfcc=20)
C.shape # (2, 20, 65) = (..., n_lfcc, n_frames)

Differentiable on torch, resident on the GPU, same array-library passthrough as everything else: (..., time) in, (..., n_lfcc, n_frames) out.

Parameters beyond the spectrogram

  • n_lfcc: coefficients kept (first rows of the DCT), at most n_filter.
  • n_filter: number of linear triangular filters (default 128), peak-1, spread evenly from fmin to fmax (None means sr / 2).
  • lifter: sinusoidal liftering parameter, weighting coefficient k by 1 + (lifter/2) sin(pi k / lifter); 0 disables.
  • top_db: clamp the dB spectrogram at max - top_db per item before the DCT; the default None applies no clamp.
  • eps: floor inside the log, 10 * log10(max(energy, eps)); default 1e-10.

Framing (n_fft, hop_length, win_length, window, center) is as in STFT. For float16 inputs the DCT and lifter stages compute in float32 and the result is cast back to float16.

The configured form

t = specux.LFCC(sr=16000, n_lfcc=13)
C = t(x) # (..., n_lfcc, n_frames)
assert specux.LFCC(**t.to_dict()) == t