Cepstral Features
Cepstrum
When we look at the spectrum of a sound — say, a human voice — it is never just a smooth curve. We always see something like a jagged mountain range: peaks rising at nearly equal distances from each other, and beneath them a smoother, rounded shape that outlines the overall contour. These two elements — the fine teeth and the smooth envelope — carry completely different information, yet in the spectrum they are superimposed and difficult to separate.
In a speech signal, for example, the teeth come from the rhythmic closures of the vocal folds — they determine the pitch of the voice. The smooth envelope, on the other hand, is shaped by how the mouth, tongue, and lips modify the path of the sound — it is precisely this that makes vowels sound different ("a" vs. "o"). These two processes operate simultaneously, and their results are mixed in the spectrum in a way that is hard to untangle directly.
Cepstral analysis offers a clever workaround. If we take the spectrum and move to a logarithmic scale, the smooth envelope and the jagged structure — which were multiplied together — become added instead. They are no longer fused; they are simply two different things placed on top of each other. Then we apply the inverse Fourier transform and obtain what we call the cepstrum. In this new domain, things arrange differently: the components responsible for the smooth envelope gather near the beginning, while those that draw the teeth pop up further away as distinct peaks. Thus, the two components that were indistinguishable in the spectrum become clearly separated in the cepstrum.
This separation is why cepstral analysis is so important in speech processing — it allows us to examine separately what the person is saying and what voice they are using, without losing the information we need for either task.
Formally, the cepstrum is defined as the inverse Fourier transform (IFFT) of the logarithm of the power spectrum:
The resulting sequence c(n) is in the so-called quefrency domain (a play on the word "frequency"). The independent variable n has units of time, but it represents periodicities in the spectrum rather than time itself. Peaks in the cepstrum at certain quefrencies correspond to harmonic spacings in the spectrum — in speech, this reveals the fundamental frequency (pitch) of the speaker. The lower quefrencies correspond to the smooth envelope of the spectrum — the filter characteristics of the vocal tract.
Important: The cepstrum uses only the magnitude spectrum — the phase information is discarded. This is acceptable because the phase tends to be less informative for the source-filter separation problem.
MFCC (Mel-Frequency Cepstral Coefficients)
MFCCs are the most widely used cepstral features in speech and audio processing. They follow the same general idea as the cepstrum, but they introduce two key modifications:
- The spectrum is filtered through a bank of triangular filters distributed along the Mel scale — a perceptual frequency scale that approximates the nonlinear frequency resolution of the human ear. The Mel scale is approximately linear below 1 kHz and logarithmic above it, meaning we have better resolution at low frequencies.
- The energy from each filter is logarithmically compressed, and then a Discrete Cosine Transform (DCT) is applied, rather than the full inverse FFT. The DCT produces a compact set of coefficients — typically 13 to 20 — that are decorrelated and capture the most important information.
The computational steps for MFCC extraction are as follows:
- Apply a window function (e.g., Hamming) and compute the FFT for each frame.
- Pass the magnitude spectrum through a Mel filter bank consisting of 20–40 triangular filters spaced according to the Mel scale.
- Compute the logarithm of the energy in each filter.
- Apply the DCT to the log-energy vector, producing the MFCCs.
The first few coefficients (usually excluding the zeroth coefficient, c0, which represents the total energy) capture the overall spectral shape, while higher coefficients represent finer details. In practice, the first 13 coefficients are most common, often augmented with the zeroth coefficient if energy information is needed. MFCCs are the de facto standard in speaker identification, speech recognition, audio classification, and even medical diagnostics such as detecting voice disorders.
Dynamic features: To capture temporal changes, first and second derivatives of the MFCCs (delta and delta-delta coefficients) are often added. These describe how the MFCCs evolve over time, which is critical for capturing transitions in speech and other time-varying signals.
Normalization: In many systems, MFCCs are normalized using Cepstral Mean and Variance Normalization (CMVN) to reduce the influence of the recording channel and background noise.
MFCC Coefficients chart
The bar chart below shows a typical set of 12 MFCC coefficients (excluding the zeroth coefficient). These coefficients describe the spectral envelope of the signal.
The first few coefficients (C1, C2, C3) typically have larger magnitudes and represent the broad shape of the spectrum. Higher coefficients (C6 and above) represent finer spectral details and are often closer to zero. In practice, these 12 numbers serve as a compact "fingerprint" of the sound.
LPCC (Linear Predictive Cepstral Coefficients)
LPCCs are obtained from Linear Predictive Coding (LPC) — a method that models the vocal tract as an all-pole filter. The LPC coefficients represent the filter that best predicts the next sample from previous samples. These coefficients are then transformed into the cepstral domain using a recursive formula, producing the LPCCs.
LPCCs were widely used in early speech recognition systems and in speech coding applications (e.g., GSM mobile telephony). They are closely related to the spectral envelope, but unlike MFCCs, they do not use a perceptual scale. In modern systems, MFCCs have largely replaced LPCCs because MFCCs are more robust to noise and better match human perception.
Nonetheless, LPCCs are still encountered in some legacy systems and in applications where computational simplicity and a direct link to the vocal tract model are important, such as low-bit-rate audio coding (e.g., MP3, AAC, where the spectral envelope is represented in the cepstral domain).
Cepstral Analysis – Visual Explanation
The plots below illustrate the key idea behind cepstral analysis. We start with a spectrum that contains both a smooth envelope and fine harmonic peaks. In the logarithmic domain, these two components become additive, and after the inverse Fourier transform, they separate clearly in the cepstrum.
Spectrum: The blue line shows the spectrum (envelope × harmonics). The orange dashed line shows the smooth envelope (vocal tract response). In this domain, they are multiplied and cannot be separated easily.
Log spectrum: After taking the logarithm, the envelope and harmonics become additive. The green line shows the log spectrum; the orange dashed line shows the log envelope.
Cepstrum: The inverse Fourier transform of the log spectrum. The smooth envelope gathers near zero quefrency (left). The harmonic peaks appear as distinct spikes further to the right.