S7 · Lesson 41 · The cepstrum and homomorphic processing
Taking the logarithm of a spectrum to separate things that were convolved together
Linear filters separate signals that were added. Many signals are combined by convolution instead: a voice is a pulse train from the vocal cords convolved with the throat's resonances; a recording is a sound convolved with a room's echoes. In the frequency domain convolution becomes multiplication, and a logarithm turns multiplication into addition. Take the inverse transform of the log spectrum and the convolved parts land in different places along a new axis, called quefrency. The result, punningly named the cepstrum in 1963, finds echoes, measures the pitch of a voice, and underlies the mel-frequency cepstral coefficients that speech recognizers used for decades. Lesson 13's minimum-phase systems fall out of it too.
- The log-magnitude spectrum of a signal with an echo of strength and delay samples: , a ripple that repeats every in frequency.
- A ripple that's periodic in frequency is a single "frequency" of its own, and its inverse transform puts a peak at quefrency . Change the echo's delay: the ripple tightens and the peak moves out.
Predict
A recording sampled at 8 kHz contains an echo delayed by 25 ms. At what quefrency index will its cepstrum show a peak?
25 ms at 8000 samples per second is 200 samples, and the echo's log-spectrum ripple repeats every radians per sample, so its cepstrum peaks at quefrency 200 (and smaller peaks at 400, 600, …). Quefrency is measured in samples, or seconds: it's a time.
Name it
The cepstrum
The real cepstrum of is the inverse DFT of its log magnitude spectrum:
The complex cepstrum uses the complex logarithm (log magnitude plus unwrapped phase) and can be inverted. If , then , and the cepstrum is the sum of the two signals' cepstra: convolution has become addition.
Echoes
For an echo, with :
so the complex cepstrum has impulses at with amplitudes (the "rahmonics"). The real cepstrum is the even part, with half those amplitudes at
Pitch and envelope
Voiced speech is a pulse train at the pitch period convolved with the vocal tract's slowly varying response. In the cepstrum, the vocal tract occupies low quefrencies (a few milliseconds), while the pitch shows as a peak at and its multiples. Keeping only the low quefrencies (liftering) smooths the spectrum into the vocal-tract envelope; finding the peak above them gives the pitch.
Minimum phase
A system is minimum phase exactly when its complex cepstrum is zero for . Folding a real cepstrum onto positive quefrencies (, for , zero for ) gives the minimum-phase system with the same magnitude, the companion of lesson 13's all-pass decomposition.
Worked example
An echo of strength 0.5 is delayed 200 samples. List the first three complex-cepstrum impulses and the real cepstrum's value at quefrency 200.
Show the solution
- Complex cepstrum. The impulses fall at multiples of the delay:
- Real cepstrum. The real cepstrum is the even part, so at ±200 it's 0.25.
- In a recording. A measured cepstrum of a noisy recording shows a peak near 0.24 there, on top of the source's own cepstrum.
Answer 0.5 at 200, −0.125 at 400 and 0.0417 at 600; the real cepstrum is 0.25 at quefrency 200.
Worked example
A voice has a pitch of 125 Hz and is sampled at 16 kHz. Where does its cepstral pitch peak appear, and how many low-quefrency coefficients should a lifter keep to capture the vocal-tract envelope without the pitch?
Show the solution
- Pitch peak. The pitch period is 8 ms, 128 samples, so the peak is at quefrency 128.
- Lifter. The vocal tract's features vary over a few milliseconds; keeping the first 30 or so coefficients (under 2 ms) captures the envelope and stays well below 128.
- Higher voices. For a 300 Hz child's voice the peak moves to 53, so the lifter must stay below the shortest pitch period expected, which is set by the highest pitch.
Answer the pitch peak is at quefrency 128, and a lifter keeping about the first 30 coefficients captures the envelope.
Worked example
Folding a real cepstrum that is 0.1 at = ±1 and zero elsewhere except = 0: what minimum-phase system results, to first order?
Show the solution
- Fold. and zero for other .
- Match to a system. Since , a cepstrum of 0.2 at = 1 is, to first order, the system
- Check. Its zero at −0.2 is inside the unit circle: minimum phase, as folding guarantees.
Answer to first order, .
Check
An echo arrives 12.5 ms after the direct sound in a recording sampled at 8 kHz. At what quefrency index does its first cepstral peak appear?
Check
An echo of strength 0.5 gives complex-cepstrum impulses at multiples of its delay. What is the amplitude of impulse number 2?
Check
A voice with pitch 125 Hz is sampled at 8 kHz. At what quefrency index is its cepstral pitch peak?
Check
An echo of strength 0.5: what value does the real cepstrum show at the echo's delay?
Check
Why can't an ordinary linear filter separate a voice's pitch pulses from its vocal-tract resonances, while the cepstrum can?
Check
Expand the log of an echo, with .
Step 1
What is the coefficient of ?
Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.
Step 2
And of ?
Check
Detect an echo with the cepstrum. Make s = numpy.random.default_rng(seed).standard_normal(8192) and x = s plus a = 0.3 times s delayed by D = 200 samples (zeros before the start). Compute the real cepstrum c = numpy.fft.ifft(numpy.log(numpy.abs(numpy.fft.fft(x)))).real, and set D_est, the index of the largest value of c between 20 and 4096, and peak, the value there.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Explain why
A speech recognizer computes mel-frequency cepstral coefficients and keeps only the first dozen. Explain why keeping low quefrencies captures what was said while ignoring who said it at what pitch.
A voiced sound is a pitch pulse train convolved with the vocal tract's response, and the vocal tract's shape, which determines the vowel or consonant, sets the spectrum's broad envelope. In the cepstrum, convolution becomes addition: the slowly varying envelope lands at low quefrencies, while the pitch, a fine ripple every hertz in the spectrum, lands at a high quefrency, the pitch period. Keeping only the first dozen coefficients keeps the envelope, the information about which sound was made, and drops the pitch peak, which depends on the speaker and intonation. The mel warping before the cepstrum spaces frequencies the way hearing does, so the coefficients emphasize the differences listeners use.
Practice
Keep practicing
7 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.