S741 of 55
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

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 a and delay D samples: log⁡|1+ae−jωD|, a ripple that repeats every 2π/D 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 D. 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?

Name it

The cepstrum

The real cepstrum of x[n] is the inverse DFT of its log magnitude spectrum:

c[n]=IDFT{ln⁡|X(k)|}

The complex cepstrum uses the complex logarithm (log magnitude plus unwrapped phase) and can be inverted. If x=s*h, then ln⁡X=ln⁡S+ln⁡H, and the cepstrum is the sum of the two signals' cepstra: convolution has become addition.

Echoes

For an echo, H(z)=1+az−D with |a|<1:

ln⁡(1+az−D)=az−D−a22z−2D+a33z−3D−⋯

so the complex cepstrum has impulses at D,2D,3D,… with amplitudes a,−a2/2,a3/3,… (the "rahmonics"). The real cepstrum is the even part, with half those amplitudes at ±D,±2D,…

Pitch and envelope

Voiced speech is a pulse train at the pitch period T0 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 T0 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 n<0. Folding a real cepstrum onto positive quefrencies (c^[0]=c[0], c^[n]=2c[n] for n>0, zero for n<0) 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
  1. Complex cepstrum. The impulses fall at multiples of the delay: x^[200]=a=0.5x^[400]=−a2/2=−0.125x^[600]=a3/3=0.0417
  2. Real cepstrum. The real cepstrum is the even part, so at ±200 it's 0.25.
  3. 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
  1. Pitch peak. The pitch period is 8 ms, 128 samples, so the peak is at quefrency 128.
  2. 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.
  3. 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 c[n] that is 0.1 at n = ±1 and zero elsewhere except c[0] = 0: what minimum-phase system results, to first order?

Show the solution
  1. Fold. c^[1]=2×0.1=0.2 and zero for other n>0.
  2. Match to a system. Since ln⁡(1+bz−1)=bz−1−…, a cepstrum of 0.2 at n = 1 is, to first order, the system 1+0.2z−1
  3. Check. Its zero at −0.2 is inside the unit circle: minimum phase, as folding guarantees.

Answer to first order, 1+0.2z−1.

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, ln⁡(1+ax) with x=z−D.

Step 1

What is the coefficient of x?

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°.

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.

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.