A robot hears your voice and the room at the same time. Pick a cleaner, push the noise up, and watch which cells of the sound each method keeps and which it throws away.
Learn how a machine pulls speech out of noise: the grid it looks at, the three ideas behind every cleaner, the networks that learned them, and the clock they must beat.
Press a cleaner, then drag the noise level and switch on the door slam. Compare the number under the picture. Then we build, piece by piece, everything underneath: the sound grid, the subtraction, the Wiener gain, the masks, the networks, the echo, the scores, and the real-time deadline.
You need a feel for what a decibel is (a way to count loudness in ratios) and a little Python for the code. We build the rest from zero.
Built from primary sources, not from slides: the papers behind RNNoise, DCCRN, Demucs, DeepFilterNet and DNSMOS, the ITU and STOI quality metrics, Boll’s spectral subtraction, the Ephraim and Malah estimators and a Texas Instruments echo-canceller note. Every link is in the Field Guide. Every idea is re-taught here in our own words and devices.
A toy sound grid, the same on every visit: 56 time frames by 36 frequency bins, three syllables of moving harmonics and one hissy consonant over noise that is louder at low pitch. Noise and speech add as power (the cross-term is dropped). Subtraction and Wiener estimate the noise from the first six silent frames, as a real system does. The “learned mask” is the ideal ratio mask, which peeks at the clean speech, plus a random 1.5 dB error in every cell: it shows the ceiling a trained network aims at, not a trained network. The score is the signal-to-error ratio of the magnitudes, in dB.
Chapter 0
See why a robot that listens in a real room never hears clean speech, and name the four things that spoil it
A small robot sits on a kitchen counter. A fridge hums behind it. A dishwasher runs in the next room. You stand two metres away and say, “Turn left.” The robot’s microphone records your voice. It records the fridge too, and the dishwasher, and the sound of its own motors.
You hear the sentence easily. Your ear and brain pull one voice out of the mess without effort. The microphone cannot do that. It adds every sound into one wiggling line, and the recogniser that reads this line must work out the words from the sum.
This lesson is about the stage that does the pulling: speech enhancement, the processing that takes a recording of speech mixed with other sounds and returns speech that is easier to understand, easier to listen to, or both. We build it from zero, from the first idea of 1979 up to the small neural networks that now run on a robot’s own chip.
A microphone in a room picks up four unwanted things. Each one needs a different tool, so it helps to name them now.
Noise is any sound that is not the voice you want: a fan, a crowd, wind, traffic. Echo is the robot’s own loudspeaker. When the robot talks, its voice leaves the speaker and returns to its own microphone. Reverberation (reverb for short) is your voice bouncing off walls and arriving late, a smear of copies of the words you just said. Ego-noise is the sound the robot makes by moving: servo whine, fan, gear rattle.
Chapters 1 to 6 handle noise, which is the core problem. Chapter 7 handles echo and reverb, which are not noise at all, because they are copies of speech. Chapter 8 teaches how to score the result. Chapter 9 puts the whole thing on a clock, because a robot cannot wait.
Engineers sum up a noisy recording with one number, the signal-to-noise ratio (SNR). It compares the power of the voice with the power of everything else, and we write it in decibels (dB). A decibel is a way to count loudness in ratios: 10 dB means ten times the power, 20 dB means a hundred times, and 0 dB means equal power. The formula is simple.
A quick check: if the voice has ten times the power of the noise, the ratio is 10, its logarithm is 1, and the SNR is 10 dB. If the noise is twice as strong as the voice, the ratio is 0.5, and the SNR is about −3 dB.
Sound spreads out as it travels. In open air, its power spreads over a sphere, so each doubling of distance cuts the level by about 6 dB. The fridge does not care where you stand. Its level at the microphone stays the same. So when you step back, your voice falls and the noise stays put, and the SNR drops with your voice.
Try the numbers. A person talking at normal effort makes roughly 60 dB of sound pressure level (SPL, a loudness scale where 0 dB is the quietest sound we hear) at one metre. Move them back, raise the noise, and watch the voice slide under it.
Top: the level of the voice (warm) and of the room noise (blue) at the microphone. Bottom: the SNR for every distance, with your position marked. Drag the distance and the noise level.
Illustrative: the voice is 60 dB SPL at 1 m and loses 20 log10(d) dB at distance d, the free-field rule. A real room adds reverberation, which makes the loss slower and the sound muddier. The noise level is a number you choose; a quiet room is near 35 dB SPL and a loud kitchen can pass 70.
At 2 m with 55 dB of noise, the voice is already below the noise. A person can still follow it, because ears use pitch and timing to separate the two. A simple recogniser cannot. That gap is the whole problem.
Who will read the cleaned signal? Two very different readers, and they want different things.
A recogniser (automatic speech recognition, or ASR) turns audio into words. It wants the cleaned audio to keep every speech sound it needs, even if a little noise stays. A listener is a person who hears the audio, on a call or from the robot’s speaker. The listener wants the noise gone and the voice to sound natural. A cleaner that scrubs hard can make a listener happy and still hurt a recogniser, because it also scrubs faint consonants. The chapters on scoring show how to measure each goal.
For a robot there is a third constraint that a recorded-audio tool never faces: time. The robot must clean each slice of sound before the next slice arrives, with a small delay, on a small chip. Every method in this lesson is judged on quality and on that clock.
The lesson follows the history of the idea, because each step fixes the one before it. We start with the picture all methods share, then subtract noise, then trust each cell by how clean it looks, then let a network learn the answer, then deal with echo and reverb, then score and deploy.
Chapter 1
Turn a recording into a picture of pitch against time, because that picture is where every cleaner does its work
Open a recording of someone speaking in an audio editor. You see a fat, wiggling line. You can tell where the person paused, and not much else. You cannot see which bumps are the voice and which are the fridge. The wiggle hides what the sound is made of.
Now open the same recording as a spectrogram. You see bright horizontal stripes that rise and fall with the speaker’s pitch, and a soft, even fog under everything. The stripes are the voice. The fog is the noise. The eye separates them at once. That picture is the one idea behind almost every speech enhancer: make a grid where the voice and the noise land in different places, then keep one and drop the other.
A microphone gives a stream of numbers. Each number is the air pressure at one instant. The sampling rate says how many numbers arrive each second. At 16 kHz, you get 16,000 numbers a second, and each number is a sample. Speech for phone calls and recognisers usually uses 16 kHz. Music and high-quality calls use 48 kHz.
A single sample says nothing about pitch. You need a slice of time. So we cut the stream into short pieces called frames, each a few tens of milliseconds long. Inside one frame, speech is nearly steady: the vocal cords vibrate at one pitch for that moment. A frame of 20 ms at 16 kHz holds 320 samples.
Take one frame. Ask: how much of a 100 Hz pure tone is in this slice? How much of a 150 Hz tone? How much of 200 Hz? The Fourier transform answers all of these questions at once. It takes N samples in and gives back N/2 + 1 numbers out, one for each tone it can test. Each tested tone is a bin.
Bins are evenly spaced. The spacing is the sampling rate divided by the frame length in samples: fs / N. For N = 512 samples at 16 kHz, the spacing is 31.25 Hz, and there are 257 bins from 0 to 8 kHz.
Each bin holds one complex number, which carries two facts. Its magnitude says how loud that tone is in the frame. Its phase says where in its cycle the tone was when the frame began. The spectrogram plots only magnitude. Phase looks like random scatter, but it matters: chapter 6 shows why ignoring it costs quality.
Cutting a frame out with scissors makes a sharp edge at each end. The transform sees that edge as a click and spreads it across all bins. So we fade each frame in and out with a smooth bump called a window. The common choice is the Hann window. RNNoise uses a Vorbis window with the same job.
A window throws away the frame’s edges, so we slide forward by less than a full frame. The step is the hop. With a hop of half the frame, every sample appears in two frames, and the faded edges of one frame are covered by the centre of its neighbour. The overlapping windows combine to a constant. This is the Princen-Bradley condition, and it is what lets us rebuild the audio later by adding the frames back, called overlap-add. RNNoise uses 20 ms frames with a 10 ms hop.
Follow the shapes for one second of 16 kHz audio with N = 512 and hop 256. The input is a vector of 16,000 reals. Framing gives about 62 frames of 512 samples each. The transform gives a complex array of about 62 × 257. Magnitudes alone are a 62 × 257 picture. That array, [frames, bins], is the grid. From here on, a cleaner is a function that edits cells in that grid.
pythonimport numpy as np def stft(x, n=512, hop=256): w = np.hanning(n) starts = range(0, len(x) - n + 1, hop) return np.stack([np.fft.rfft(w * x[s:s+n]) for s in starts]) # [frames, n//2+1] complex
Here is the catch. A long frame has many samples, so the bins are closely spaced and you can tell two nearby pitches apart. But a long frame averages over a long time, so a short click smears across it. A short frame pins down timing and blurs pitch. You cannot have both. This is a hard limit of the transform, not a flaw in the code.
For speech the pitch matters twice. The voice of a man sits near 100 to 130 Hz, a woman near 200 Hz. The lines you see in a spectrogram are harmonics: copies of the pitch at two times, three times, four times its frequency. To keep the voice and drop the noise between the harmonics, the grid must resolve them. Try it. The voice below has a pitch near 130 Hz. A click arrives at 0.3 s.
The voice is a stack of harmonics, 130 Hz apart. The white tick marks a click at 0.3 s. Pick a window length and look for two things: can you see separate lines, and how wide is the click?
A real computation in your browser: a synthetic voice (20 harmonics of a pitch that glides from 130 to 142 Hz, each harmonic 1/h as loud) plus one click, sampled at 16 kHz, analysed with a Hann window and a hop of half a window. The display shows 0 to 2 kHz. A Hann window spreads each tone over about four bins, so two tones need to be at least four bins apart to look separate.
At 16 ms the harmonics merge into a smear, because four bins of 62.5 Hz are 250 Hz wide and the lines are only 130 Hz apart. At 32 ms the lines separate. At 64 ms the lines are sharp, but the click is spread over 64 ms and the glide of the pitch starts to blur too.
A real-time system picks a window near 20 ms, which is the RNNoise choice, At 48 kHz a 20 ms window gives bins 50 Hz apart. One tone spreads over about four bins, which is 200 Hz. A low male voice has harmonics only 100 to 130 Hz apart, so they blur together. This is exactly why RNNoise adds a separate pitch filter in chapter 5, and why DeepFilterNet uses a different trick in chapter 6. Both fight the same limit you just saw.
A cleaner built on this grid has three steps. Analysis turns the audio into the complex grid. Processing multiplies each cell by a number between 0 and 1, called a gain: 1 keeps the cell, 0 deletes it. Synthesis runs the inverse transform on each edited frame and overlap-adds them into audio. Everything from chapter 2 to chapter 4 is a different way to choose the gain.
Chapter 2
Listen to the room before anyone talks, then subtract what you heard from every frame, and learn why the result sings
You press record in a quiet-looking room. For the first half second nobody speaks. The microphone hears only the fridge. Then you start talking. A person who knew only the first half second could say, “That hum is what the room sounds like. Everything extra must be the voice.”
That is the whole idea of spectral subtraction, published by Steven Boll in 1979. Measure the noise while no one speaks. Subtract that measurement from every later frame. What remains is the voice. It is the oldest method in this lesson, and every newer method is a reaction to its flaws.
Take one cell of the grid from chapter 1: one frame, one bin. The microphone records the sum of the voice and the noise in that cell. In complex numbers, Y = S + N. Noise and speech have nothing to do with each other, so on average their cross-term cancels, and the powers simply add:
Rearrange, and you get the estimate. Replace the unseen noise power by an estimate N̂2 (the average noise power for this bin, measured in the silent frames). The voice power estimate is |Y|2 minus that. Because we edit the grid with gains, we write the same thing as a gain on the amplitude:
Work two cells by hand with α = 1. A cell where the mic measures |Y|2 = 10 and the noise average is 4: the ratio is 0.4, so 1 − 0.4 = 0.6, and G = √0.6 = 0.775. The output power is 0.7752 × 10 = 6. The noise average of 4 was removed. A second cell has |Y|2 = 3 and the same noise average of 4. The subtraction would go negative (1 − 1.33), which is impossible for a power. So we clip it to zero, and the floor takes over. With gmin = −20 dB the cell keeps a gain of 0.1, and its output power is 0.01 × 3 = 0.03.
Boll subtracted “the spectral noise bias calculated during nonspeech activity.” In practice, a system averages the power of each bin over the frames it believes contain no speech. The device below does the simplest version: it averages the first six frames, which are silent in our toy, and smooths each bin a little with its two neighbours. Real systems keep updating that average. They use a voice activity detector (a small classifier that says “speech now” or “no speech now”) or track the quietest recent values per bin.
The method rests on an assumption: the noise is stationary, which means its average does not change over time. A fridge qualifies. A door slam does not. We will test both.
Now run it on real noise. Here is the subtle part. The noise power in one cell is not equal to its average. It fluctuates, frame to frame, around the average. Some cells are twice the average. Some are a tenth. Statistically, this is an exponential spread: the power in a Gaussian-noise cell is very often small and occasionally several times its mean.
Subtracting the average treats every cell as if it sat exactly at the average. A cell that happens to be above the average keeps a positive leftover. Its neighbours, below the average, fall to zero. The result is a scatter of isolated bright specks that appear in one frame and vanish in the next. The ear hears each speck as a very short pure tone, and a few hundred of them per second sound like a warbling, bubbling tune. Engineers call it musical noise, and many listeners find it more annoying than the original noise.
The symptom is the warble. The measurement is to count the specks in cells that hold no speech at all. The fix has two knobs. Raise α so the subtraction overshoots the average and fewer cells survive. Raise the floor so that the leftover is a steady low hiss, which masks the specks. Both cost something, and the device shows what.
Left: the noisy grid at 5 dB. Right: after subtraction. Red dots mark specks, cells with no speech that still hold noise. Drag α up and the floor down, then switch on the door slam.
The toy grid of the hero at 5 dB: power-additive speech and exponentially distributed noise, noise estimate from the first six silent frames. A speck is a cell with no speech whose output power is more than half the noise estimate. The score is the signal-to-error ratio of the magnitudes in dB. All numbers are computed live from the grid.
With α = 1 and the lowest floor, about three in ten silent cells keep a speck. Push α to 3 and the specks nearly vanish, but now the output keeps less of the speech energy, because the subtraction also bites into the quiet parts of words. The door slam adds a different failure. It arrives after the estimate was taken, so the estimate does not know it exists, and much of the noise energy now passes through (75% at the defaults).
Chapter 3
Stop subtracting a fixed amount and choose each cell’s gain by how clean that cell looks, then smooth the guess over time
You are in a loud bar and a friend is telling you a story. You catch some words clearly, because she raised her voice. You miss others, because a glass broke. For each word, you decide how much to trust what you heard. A clear word you accept. A word drowned in noise you mostly ignore and fill in from context.
A cleaner can do the same for each cell of the grid. Chapter 2 treated every cell alike: subtract the same noise average from all. But a cell with strong speech and a cell with almost none are in very different situations. The first deserves a gain near 1. The second deserves a gain near 0. The Wiener filter, named after the mathematician Norbert Wiener, gives the best gain for each cell if you know how clean it is.
For one cell, call the average speech power Ps and the average noise power Pn. Their ratio is the a priori SNR, written ξ (xi): ξ = Ps / Pn. “A priori” means “before looking at this frame”: it is the cleanliness we expect, not the noisy value we just measured. A cell with ξ = 3 has three times as much speech as noise. A cell with ξ = 0.1 is mostly noise.
We want a number G so that G × Y is as close as possible to the true speech S. “Close” means a small average squared error. The error of one cell is S − G(S + N). Square it and take the average. Speech and noise are unrelated, so the cross-term vanishes:
This error has two parts that pull in opposite directions. A big gain keeps the speech (first term small) but lets noise through (second term large). A small gain kills the noise but also the speech. Set the slope to zero to find the balance: −2(1 − G)Ps + 2G Pn = 0. Solve it: G = Ps / (Ps + Pn). Divide top and bottom by Pn:
Check four values. ξ = 10 gives 10/11 = 0.91, almost full keep. ξ = 3 gives 0.75, or −2.5 dB. ξ = 1, a cell where speech and noise are equal, gives exactly 0.5, or −6 dB. ξ = 0.1 gives 0.09, or about −21 dB, a heavy cut. The gain slides smoothly. Nothing is a hard yes or no.
Horizontal: how clean a cell is (ξ, in dB). Vertical: the gain it receives, in dB. Pink: Wiener. Yellow: spectral subtraction at your α. Drag ξ along the curve and change α.
Exact formulas. Wiener: G = ξ/(1+ξ). Subtraction, for a typical cell where the measured power is speech plus noise, so |Y|2/Pn = 1 + ξ: G = √max(1 − α/(1+ξ), 0). Gains are amplitude gains, shown in dB.
Compare the curves. At α = 1 the subtraction gain is exactly the square root of the Wiener gain, so it cuts less: at ξ = 3 it keeps 0.87 where Wiener keeps 0.75. Raise α above 1 and the curve cuts harder, then hits zero at ξ = α − 1 with a sharp corner. Both are members of one family: a gain that rises from 0 for dirty cells to 1 for clean cells. They differ in the shape of the rise, and the sharp corner is what makes subtraction twitchy and musical.
The microphone gives us |Y|2, not Ps. The first guess uses the measured power: ξ ≈ |Y|2/N̂2 − 1, clipped at 0. That is jumpy for the same reason as before: one cell is one random draw. The fix is from Ephraim and Malah (1984). It is called the decision-directed estimate. Instead of trusting this frame alone, it blends the raw guess with what the cleaner decided last frame: it takes the cleaned power of the previous frame, divides by the noise estimate, and mixes it in with weight a.
A lone bright speck now meets resistance. Last frame this bin was clean, so the blend says “probably still clean,” and the gain stays low. A real speech onset takes a few frames to climb, which is the price: the smoother the estimate, the later the first sound of a word comes through. Symptom: the consonant at the start of a word is clipped. Measurement: the fraction of speech energy kept falls. Fix: lower the smoothing weight a, accepting a few more specks.
The same noisy grid at 5 dB. Drag the smoothing weight a from 0 (trust only this frame) up to 0.9 (trust the last decision). Watch the specks and the speech kept.
Toy: the Wiener gain ξ/(1+ξ) with ξ from the decision-directed rule, a floor of −25 dB, noise estimate from the six silent frames, 5 dB input. Real systems use larger weights and the full MMSE amplitude estimator of Ephraim and Malah; this is the Wiener member of the family.
At a = 0 the gain follows each cell’s own luck and about one in five silent cells keeps a speck. At a = 0.7 specks fall to roughly one in eight while the score rises. Push to 0.9 and the score begins to fall: the filter is now too slow to follow the syllables.
Chapter 4
Treat the gains as a picture, build the perfect picture from known mixtures, and teach a network to guess it from the noisy sound alone
A teacher has a printed grid of a spectrogram and a yellow highlighter. She is told: “Mark every cell that belongs to the voice.” She does not subtract anything. She just marks. When she is done, you can multiply the grid by her marks and get a cleaned spectrogram.
That marking sheet is a time-frequency mask: a grid the same size as the spectrogram, with a gain in each cell. Chapters 2 and 3 computed the mask by a formula from a noise estimate. A neural network does not need that formula. It looks at the noisy grid and predicts the mask directly. The question for this chapter is: what mask should it learn to predict?
To train a network you need pairs: a noisy input and the right answer. Real recordings never come with the right answer, because nobody can unmix a fridge from a voice after the fact. So engineers make the mixtures themselves. They take clean speech recorded in a quiet studio, take noise recordings of fans, crowds and cars, and add them at a random SNR. RNNoise’s authors built training data this way, with noise types such as computer fans, office, crowd, airplane, car, train and construction, mixed at levels that give a wide range of SNRs.
Because we added the two ourselves, we know S and N in every cell. That lets us compute an ideal mask, the best possible gain for that mixture. The network sees only the mixture Y. Its job is to guess the ideal mask from Y. The loss measures how far the guess is from the ideal mask, or from the clean spectrum it should produce.
The ideal binary mask (IBM) is the teacher’s highlighter at its simplest. A cell gets 1 if the speech beats the noise by a margin, and 0 otherwise. The margin is the local criterion, in dB. It is a yes-or-no mask.
The ideal ratio mask (IRM) is soft. Its gain is the share of the cell that is speech, raised to a power β. With β = 0.5, the gain is √(S2/(S2 + N2)). Wang, Narayanan and Wang (2014) compared training targets for supervised speech separation and found that ratio-style masks outperform spectral-envelope targets and give better measured intelligibility and quality.
The complex ratio mask (CRM) has a real part and an imaginary part. It does not only scale a cell, it also rotates it. DCCRN, in chapter 6, predicts this kind.
Two cells by hand. Cell A: speech power 8, noise power 2. The ratio 4 is 6 dB, above a criterion of 0 dB, so IBM = 1. The IRM is 8/(8+2) = 0.8, and with β = 0.5 the gain is 0.89. Cell B: speech 1, noise 4. The ratio is below the criterion, so IBM = 0. The IRM is 1/5 = 0.2, and the gain is 0.45. The soft mask never says “zero.” It says “mostly noise, keep a little.”
The device applies each mask to the same noisy grid, at the SNR you set. These are ideal masks: they peek at the clean speech. That is the point. They show the best a network could do if it guessed perfectly, and the third option shows what a guess with a little error costs.
Left: the mask (brighter pink means a higher gain). Right: the noisy grid after the mask is applied. Choose a target, then move its knob.
The toy grid of the hero. Binary: the slider is the criterion LC in dB. Ratio: the slider does nothing. Ratio + error: the slider sets a random gain error per cell, in dB, taken as its absolute value, standing in for an imperfect network. The score is the signal-to-error ratio of the magnitudes. In this toy the ideal ratio mask is exact because speech and noise add without a cross-term, and the readout shows “over 40 dB” for it. Illustrative: an actual network’s error is not random per cell; it is correlated and depends on the noise.
At a criterion of 0 dB the binary mask scores 17.6 dB on this grid and keeps 99% of the speech energy, but its hard edges leave a patchwork, and 28% of the noise energy still passes. Slide the criterion to −10 dB and more noise slips through (36%). Slide it to +10 dB and the weaker harmonics vanish (74% of the speech kept, a score of 5.8 dB). The ratio mask has no such knob, because it never decides: it keeps a share.
In this toy the ideal ratio mask recovers the magnitude exactly, because the toy has no cross-term between speech and noise. Real mixtures do, so a real ideal mask is not perfect. The third option is more useful. With a 2 dB error per cell the ratio mask scores 16.2 dB, well above the Wiener gain of chapter 3 (12.3 dB). With a 4 dB error it falls to 11.7 dB, below the formula. In this toy, a network must guess the mask to within about 3 or 4 dB to beat a hand-made formula.
Every mask here is a real number between 0 and 1. It scales a cell’s magnitude and leaves the phase of the noisy cell as it was. At high SNR this is fine: the noisy phase is close to the clean phase. At low SNR, below about 0 dB, the noisy phase is badly wrong, and the output has a roughness no magnitude mask can remove. The complex ratio mask and the waveform models of chapter 6 exist to fix this.
Follow the data flow of a training step. Input: the noisy grid, [frames, bins] or features derived from it. Output: a mask of the same shape. Target: the ideal mask built from the known S and N. Loss: a distance between the two. After many thousands of mixtures, the network learns what voice-like and noise-like cells look like in context, which a formula based on one frame cannot know.
Chapter 5
Follow one 10 ms slice of sound through a complete real-time denoiser, from raw samples to 22 gains and back to audio
You want a denoiser for a doorbell camera, a headset, a robot. The chip is small. A network that takes 1,600 million operations every second will not fit. You also cannot ask a network to produce 960 raw samples directly and hope: too hard, too big.
Jean-Marc Valin, who helped build the Opus audio codec, took a different route in 2017. He kept the parts of signal processing that already worked, and gave the network only the one job it does better than a formula: decide how loud each band should be. The result, RNNoise, is a hybrid. This chapter follows one slice of sound through it, because it is the clearest example of a network wrapped in classical code.
A full-band signal at 48 kHz has 481 bins per frame. A network that outputs one gain for each would be big. Valin noticed that you do not need that detail. The ear hears low frequencies in fine steps and high frequencies in coarse steps, so he grouped the bins into bands that follow the Bark scale, the same layout the Opus codec uses. The bands are triangular and overlap, and there are 22 of them. The network predicts one gain per band. The system then interpolates those 22 gains into 481 bin gains by sliding between neighbours.
That cuts the output of the network from hundreds of numbers to 22. It also cuts what the network has to learn: the shape of the noise spectrum across a few bands, not every bin.
The network does not read the spectrogram directly. It reads 42 numbers per frame that Valin chose by hand. The first 22 are the log energy of each band, passed through a cosine transform to remove correlation between neighbours (the result is called Bark-frequency cepstral coefficients, BFCC). Another 12 are the first and second time-derivatives of the first six of those. Six more describe how periodic each part of the spectrum is, which is the signature of a voiced sound. One is the pitch period itself. The last is a measure of how much the spectrum is changing, a hint that speech has started. That is 22 + 12 + 6 + 1 + 1 = 42.
The network has four hidden layers, 215 units in all, and the largest has 96. The core is three GRU layers. A GRU (gated recurrent unit) is a small memory cell: at each frame it reads the new features, decides how much of its old memory to keep, and writes a new memory. Memory is what lets the network know that this frame follows ten frames of speech.
Valin designed the three layers to match three jobs, though training is free to blur them. The 24-unit layer feeds a small output that says “speech or not” (a voice activity detector, VAD). The 48-unit layer estimates the noise spectrum. The 96-unit layer combines everything and outputs the 22 gains, each squeezed to the range 0 to 1 by a sigmoid. A GRU slightly beat an LSTM here and is simpler. Making the network bigger did not help much; the loss function and the training data mattered more.
Eight stages, in order. Press Next to move the highlight and read what the stage consumes and produces, with its shapes.
Every number is from the RNNoise paper (Valin, MMSP 2018): 48 kHz, 20 ms Vorbis window, 10 ms hop, 22 bands, 42 features, GRU layers of 24, 48 and 96 units. The 480-sample hop and 481 bins are arithmetic on those: 48,000 × 0.010 and 960/2 + 1. The 12 kHz pitch search and the comb filter are the paper’s design.
Recall chapter 1. At 20 ms and 48 kHz, one tone smears over about 200 Hz. A band gain is even coarser than that. A low voice has harmonics every 100 Hz or so, and noise sits in the gaps between them. A band gain cannot reach into the gaps.
So RNNoise adds a classic fix before the gains are applied. It finds the pitch period T (searching on a 12 kHz copy to save work) and filters the signal with a comb filter: a filter that adds the signal to a copy of itself delayed by exactly one pitch period. At the pitch and its harmonics the two copies line up and add. In between, they cancel. The strength of that filter in each band depends on how periodic the band is and on how much the network decided to cut it. The network never sees the comb filter’s inside; it only supplies the gains that steer it.
The network is trained by comparing each predicted band gain ĝ with the ideal gain g, computed from the clean speech and noise you made in chapter 4. The loss is (gγ − ĝγ)2 with γ = 1/2. In plain words: compare the square roots of the gains. A plain squared error would treat a miss at a gain of 0.9 and a miss at a gain of 0.05 the same. The square root makes the loss more sensitive to the small gains, so it stops the network from being timid about cutting noise. Valin notes this is equivalent to a mean squared error on the band energy raised to the power one quarter. A separate cross-entropy loss trains the VAD output, which costs only 24 weights and helps the 24-unit layer learn to tell speech from noise.
The gains also get a safety net: g̃ = max(0.6 · g̃previous, ĝ). A gain can fall by no more than 40% per frame. Without it, a sudden cut sounds unnaturally dry, and the paper notes this limit is equal to a reverberation time of about 135 ms.
The network has 87,503 weights. Each weight is used once per frame in a multiply-add, so the network needs about 175,000 floating-point operations per frame. At 100 frames per second that is 17.5 million operations per second. The two FFTs and one inverse FFT add about 7.5 million, and the pitch search adds about 10 million. The total is about 40 million operations per second. The weights can be stored in 8 bits with no loss in quality, which lets them fit in a CPU’s L2 cache.
| System | Weights | Operations per second | Sample rate |
|---|---|---|---|
| RNNoise | 87,503 | about 40 million | 48 kHz |
| A 3 × 2048 network the paper compares with | 12.5 million | 1,600 million | 16 kHz |
On a laptop-class core (a Haswell i7), the unoptimised C code uses about 1.3% of one core for 48 kHz noise suppression. On a 1.2 GHz ARM Cortex-A53, the core of a Raspberry Pi 3, it uses 14% of one core. The paper compared it with the MMSE suppressor in SpeexDSP (a classic estimator that picks the gain with the smallest average squared error, in the family of chapter 3) using PESQ and reports a clear gain, especially for non-stationary noise.
Chapter 6
Meet three networks that fix what a real-valued mask leaves behind: the phase, the grid itself, and the blur of a short window
RNNoise worked, but it left three complaints. Its gains scale magnitudes and keep the noisy phase, which is wrong at low SNR. Its 22 bands are too coarse to reach between harmonics, so it needs a pitch filter bolted on. And it runs on hand-picked features, which limit what it can learn. The three systems in this chapter each take one complaint and push it hard.
Chapter 4 ended with the phase problem. A cell of the grid is a complex number, a point on a plane. A real gain only shrinks the point toward the origin. The noisy phase, the angle of that point, stays wrong. A complex ratio mask has a real part Mr and an imaginary part Mi, and multiplying by it both scales and turns the point. With the noisy cell Y = Yr + jYi, the cleaned estimate is
This is complex multiplication. DCCRN (Deep Complex Convolution Recurrent Network, Hu and colleagues, Interspeech 2020) builds the same rule into the layers of the network. Its convolution layers and its LSTM layers keep a real stream and an imaginary stream and combine them with the complex multiplication rule, so the network treats the pair as one complex number rather than two unrelated channels. It works on 16 kHz audio with a 25 ms window and a 6.25 ms hop, is trained with a loss on scale-invariant SNR (chapter 8), and has 3.7 million parameters. It ranked first in the real-time track of the Interspeech 2020 Deep Noise Suppression (DNS) challenge, an open contest for denoisers, judged by listener mean opinion score. To fit the challenge limit of 40 ms of look-ahead, it peeks six frames ahead: 6 × 6.25 = 37.5 ms. One frame takes 3.12 ms to process on a laptop-class Intel i5.
The grid is a design choice, not a law. Défossez, Synnaeve and Adi (2020) asked: what if the network reads and writes the raw waveform itself? Then there is no phase to guess, because the waveform contains it. Their model, an adaptation of the Demucs music separator, is shaped like a letter U. An encoder is a stack of convolutions that shrink the signal in time, making each step cover more samples. At the bottom sits a two-layer LSTM. A decoder grows the signal back with transposed convolutions. Skip connections copy each encoder stage straight to its matching decoder stage, so fine detail skips the bottleneck.
For the real-time version, the LSTM is unidirectional so it never looks ahead, and the model reads a 37 ms frame with a stride of 16 ms plus 3 ms of lookahead for resampling. The loss has two parts: an L1 distance between waveforms, and a multi-resolution STFT loss that compares spectrograms at FFT sizes 512, 1024 and 2048. The second part is chapter 1 used as a teacher: it tells the model whether the grid it would produce matches the clean grid at three different time-frequency trade-offs.
It runs fast enough. On a quad-core Intel i5 at 2.0 GHz, the real-time factor (compute time divided by audio time, chapter 9) is 0.6 for the 48-channel version and 1.05 for the 64-channel one, so only the smaller one keeps up. On one core the smaller model still reaches 0.8. On the Valentini benchmark, the 48-channel causal version scored PESQ 2.93 and STOI 95, against 2.22 and 93 for a Wiener filter and 1.97 and 91.5 for the noisy input.
One more result is a lesson in itself. Mixing a small share of the noisy input back into the output (a “dry” share of 5%) lowered PESQ slightly, 2.91 to 2.88, but raised the overall listener rating from 3.39 to 3.72 in the paper’s table. Fully scrubbed audio sounds unnatural. A trace of the original room makes it sound real.
Chapter 1 showed that a short window blurs harmonics. A mask cannot repair this, because a mask only scales a cell. Schröter and colleagues (2022) noticed that a cell’s neighbours in time carry information the mask ignores. In a voiced sound, a harmonic persists across frames. So instead of one gain, they let the network output a short complex filter for each bin: a handful of complex weights, one for each of the last few frames. The cleaned cell is the weighted sum. This is called deep filtering:
DeepFilterNet works in two stages. Stage one predicts 32 gains on an ERB scale (a frequency scale like Bark) to shape the spectral envelope, cheaply. Stage two applies deep filtering up to 5 kHz, where speech has strong periodic structure, with N = 5. The authors compare deep filtering with complex masks at windows from 5 to 30 ms and find deep filtering ahead, while the mask models lose quality as the window shrinks. At a 5 ms window, the minimum algorithmic latency is 5 ms. In their comparison table, DeepFilterNet has 1.8 million parameters, about 0.35 billion multiply-accumulates per second and a wideband PESQ of 2.81. DCCRN, in the same table, has 3.7 million parameters, 14.36 billion and 2.68.
Pick a model. The bar shows the audio it reads in one go (warm), and the future audio it waits for (yellow), to scale on a 45 ms ruler. Ticks mark the step between outputs.
Numbers from the papers: RNNoise 20 ms window and 10 ms hop (Valin 2018); DCCRN 25 ms window, 6.25 ms hop, 6 frames of look-ahead (Hu et al. 2020); causal Demucs 37 ms frame, 16 ms stride, 3 ms look-ahead (Défossez et al. 2020); DeepFilterNet 5 ms window as the minimal-latency setting with no look-ahead (Schröter et al. 2022; its hop is not drawn because the paper leaves it open). The ruler shows what the paper states, not a measured end-to-end delay.
| Model | Works on | What it predicts | Size |
|---|---|---|---|
| RNNoise | 48 kHz grid, 22 bands | 22 real gains and a speech flag | 87,503 weights |
| DCCRN | 16 kHz complex grid | a complex ratio mask | 3.7 million |
| Demucs (causal) | 16 kHz waveform | the clean waveform | set by H = 48 or 64 |
| DeepFilterNet | 48 kHz grid, 32 ERB bands | ERB gains, then a complex filter of order 5 | 1.8 million |
Chapter 7
Cancel the robot’s own voice by learning the path it takes to the microphone, then shorten the room’s late copies of yours
The robot says, “Sure, turning left.” Its voice leaves the loudspeaker and, a few milliseconds later, reaches its own microphone, along with a smear of bounces off the counter and walls. The recogniser now hears the robot’s sentence as if a person had spoken it. Worse, if you interrupt (“No, right!”), the robot must hear you through its own voice. This is the problem of echo, and a noise suppressor cannot solve it. A noise suppressor treats the robot’s voice as speech, because it is speech, and keeps it.
Echo has a weakness: the robot knows exactly what it played. That signal is the far-end signal x. The microphone signal d holds your voice, noise, and a changed copy of x. If you knew how the room changed x, you could compute the copy and subtract it.
The change is the echo path, the combined effect of the loudspeaker, the air, the walls and the microphone. For a fixed room it acts like a short filter: each output sample is a weighted sum of the last L samples of x. The L weights are the taps. You do not know them, so you learn them while the robot talks, with an adaptive filter. The standard one is the normalised least-mean-squares algorithm, NLMS. Each sample it does four things. It computes an echo estimate from the current taps. It subtracts the estimate from the microphone signal to get an error. It nudges each tap to shrink that error. Then it moves on.
The Texas Instruments AIC3254 application note describes a product built on this idea: its echo canceller offers an NLMS filter of 12 ms (96 taps) or 32 ms (256 taps) at an 8 kHz sample rate, followed by a non-linear processor that suppresses the echo that is left. The quality measure is ERLE, the echo return loss enhancement: how many dB quieter the echo is after cancelling. Run the filter below. Its true echo path has 64 taps (8 ms).
Top: the true echo path (blue) and what the filter has learned (pink). Bottom: ERLE over half a second. Try a filter that is too short, a step size that is too small, and a talker who joins at 250 ms.
A real NLMS run, computed in your browser: 4,000 samples at 8 kHz, a coloured-noise far-end signal, a 64-tap decaying echo path and a little sensor noise. ERLE is the echo power over the leftover echo power in blocks of 100 samples. The “freeze” uses a perfect detector that knows when the talker is active; a real double-talk detector makes mistakes, which is why double-talk is a hard problem.
With 64 taps and μ = 0.5 the echo falls by about 40 dB within 250 ms. A 32-tap filter is shorter than the real path, so it can never cancel the tail, and it stalls near 22 dB. A 128-tap filter has enough room but more taps to learn, so it is slower (25 dB at 250 ms). A step size of 0.1 is safe but slow (18 dB). This is the standard trade-off: a longer tail costs compute and convergence time, a faster step costs steadiness.
Switch on the talker. The filter assumes the error e is leftover echo, so it adapts to shrink it. But now e also holds the talker’s voice, which has nothing to do with the far-end signal. The update chases a signal it cannot cancel and spoils the taps it had learned. In the run, ERLE drops from 40 dB to about 4 dB during the interruption, and the filter must relearn afterwards. The symptom is echo leaking back whenever someone interrupts. The measurement is ERLE during the overlap. The fix is a double-talk detector that freezes adaptation when the talker is active; with a perfect one, ERLE stays near 44 dB. The TI note pairs the NLMS stage with a non-linear processor, because a small residue of echo always remains and the processor suppresses it.
Reverberation is the sound of a room. Your voice reaches the microphone directly, then again after each bounce. The time for the level to fall by 60 dB is the room’s RT60. In a room with an RT60 of 0.6 s, the tail falls 100 dB per second, so a syllable is still 10 dB down 100 ms after it ended, and it lands on top of the next syllable. A 20 ms analysis window ends long before the tail does. That is why a mask that looks only at one frame cannot fix it, and why the late copies smear consonants and hurt recognition.
The classic fix is weighted prediction error (WPE), from Nakatani and colleagues (2010). Its idea: late reverb is a smeared copy of your earlier speech, so predict it from frames at least a gap D back, with a linear predictor learned for each frequency bin from the recording itself, and subtract the prediction. The gap D keeps the predictor away from the direct sound and the first reflections, so it removes only the late tail. No clean recording and no room measurement are needed. Most neural enhancers in chapter 6 also train on reverberant mixtures so they learn to shorten the tail.
Chapter 8
Learn what each score actually measures, which ones need a clean reference, and why one number is never enough
You have two denoisers. The first sounds cleaner to you. The second helped the recogniser make fewer mistakes. A third person likes neither. Without a way to measure, the argument never ends. Listening tests settle it, but a proper test needs many listeners and many hours. Engineers need quick numbers they can compute after every training run.
Each number measures something different. Choosing one means choosing what you care about. Start by sorting them on one question: does the score need the clean version of the recording?
An intrusive metric compares the cleaned audio with a clean reference of the same sentence. That works when you built the mixture yourself, as in chapter 4. It fails on a real recording from a kitchen, where no clean version exists. A non-intrusive metric scores the cleaned audio alone. It is the only choice for real recordings, and it is less exact because it must guess what clean would sound like.
The plain signal-to-noise ratio of the output has a weakness. If the network makes the output twice as loud, the score changes even though the voice and the noise are in the same proportion. The scale-invariant SNR (SI-SNR, also written SI-SDR) removes that. It first finds how much of the estimate points along the clean signal, then calls the rest error:
The clean signal s is the long arrow along the axis. The estimate is the pink arrow. Tilt it to add error, then scale it. Compare the two scores.
Exact two-dimensional geometry. The estimate has length equal to the loudness times 1 and points at the error angle from the clean signal, so the SI-SNR is 20 log10(1/tan of the angle) for every loudness, and the plain SNR is 10 log10(1 / (1 − 2a cosθ + a2)) for loudness a.
Try the numbers. At 20 degrees the SI-SNR is 8.8 dB. Scale the estimate to 2 times and it is still 8.8 dB, but the plain SNR falls from 9.2 dB to −0.9 dB, because the louder estimate no longer sits on top of the clean signal. SI-SNR is a good training loss. But it only counts how close the waveform is. It does not know what a listener hears.
PESQ (perceptual evaluation of speech quality, ITU-T P.862) is intrusive. It was built for telephone networks. It aligns the cleaned and clean signals in time, passes both through a model of the ear, and measures the difference in loudness patterns, with extra weight on added noise over missing sound. Its output runs on a scale that tops out around 4.5. The wideband extension (P.862.2) works at 16 kHz over 50 to 7000 Hz. A trap: several versions exist, with and without a later correction, and a 2025 comparison found that scores from different versions can differ by up to about 1.8 points on the same data. Always state the version and mode. RNNoise’s authors had to resample their 48 kHz output down to 16 kHz because wideband PESQ requires it.
STOI (short-time objective intelligibility, Taal and colleagues, 2011) asks a different question: not “does it sound good” but “can you make out the words.” It is also intrusive. It cuts both signals into short segments of roughly 0.4 s, splits them into one-third-octave bands, and correlates the envelopes of the clean and the cleaned versions. High correlation means the speech shape survived. It is usually quoted between 0 and 1, or as a percentage. It tracks the number of words listeners get right, but it saturates: once most words are clear, it barely moves.
DNSMOS (Reddy, Gopal and Cutler, Microsoft) is non-intrusive. The team collected listener ratings with the ITU-T P.808 crowdsourcing protocol: about 120,000 processed clips with listener ratings, made by running 600 noisy test clips through more than 200 different cleaners. A small convolutional network reads a log-power Mel spectrogram (20 ms frames, 10 ms hop, 120 bands) and learns to predict the average rating, a mean opinion score from 1 to 5. A multi-stage “self-teaching” step cleans up the noise in the labels. On the DNS challenge blind set it agreed with human ratings far better than the older metrics.
Pick a view. The first two show five systems on one benchmark. The last two show how closely each metric tracks human ratings.
Valentini rows are from Table 1 of the Demucs speech paper (Défossez et al. 2020); the first three are the noisy input, a Wiener filter and DeepMMSE, causal rows are marked. The agreement rows are Table 2 of the DNSMOS paper (Reddy et al.) on the Interspeech DNS challenge blind set. PCC is the Pearson correlation of averaged ratings per cleaner. SRCC is the Spearman rank correlation, how well the ranking matches.
Read the four views together. On Valentini, the noisy input scores a PESQ of 1.97 and the best system 3.07: a large gap. In STOI the same two read 91.5% and 95%: a small gap. Neither is wrong; they measure different things. And SDR, which is the classic signal ratio, agrees with listeners with a correlation of only 0.23, while DNSMOS reaches 0.93. A score can be precise and still not matter to a listener.
Chapter 6 gave the sharpest example. Mixing 5% of the noisy input into the Demucs output lowered PESQ from 2.91 to 2.88 and raised the listener rating from 3.39 to 3.72. A metric that compares against clean punishes the trace of noise. A listener prefers it. For a robot, add the score that matters most to your goal: word error rate of your recogniser if the audio feeds ASR, DNSMOS or a listening panel if a person hears it, and always your latency from chapter 9.
Chapter 9
Turn a model that works on a file into one that works on a live microphone, and learn which numbers decide whether it keeps up
Someone shouts “Stop!” at the robot. The words are on the way into the microphone as you read this sentence. The robot has no file to open and no end of recording to wait for. Audio arrives in small blocks, forever, and each block of cleaned audio must leave before the next block needs the processor. If the model is late once, you hear a click. If it is late often, the robot stutters.
Every model so far was described by its quality. A device cares about two more things: latency, how long the audio waits, and throughput, whether the chip can keep up at all. This chapter turns both into arithmetic.
The delay from a sound entering the microphone to its cleaned version leaving is the sum of three pieces. Algorithmic latency is built into the method. The cleaner cannot output a frame until the whole window has arrived and any look-ahead it needs. DeepFilterNet’s paper writes it as the window length plus the larger of the network’s look-ahead and the filter’s look-ahead; at a 5 ms window with none, that is 5 ms. Buffer latency comes from the audio hardware, which hands software a block of samples at a time. Compute latency is the time the processor spends on each frame.
Look-ahead is the choice you tune. DCCRN peeks six frames ahead, 6 × 6.25 = 37.5 ms, to fit the DNS challenge limit of 40 ms. The causal Demucs reads a 37 ms frame plus 3 ms of look-ahead. RNNoise uses a 20 ms window. A shorter window or less look-ahead means a quicker robot, and a model with less context to work from.
Frames arrive every hop milliseconds. The cleaner must finish each frame within one hop, or the output queue runs dry. The real-time factor (RTF) is the compute time for a frame divided by the hop. Défossez and colleagues define it as the time to enhance a frame divided by the stride. An RTF of 1 means the chip is exactly as fast as the sound. Below 1, the chip has spare time. Above 1, it falls behind further with every frame and never recovers.
The sources give real examples. The causal Demucs with 48 hidden channels has an RTF of 0.6 on a quad-core 2.0 GHz Intel i5, so one frame of 16 ms takes about 9.6 ms. The 64-channel version has an RTF of 1.05, so it cannot keep up on that machine. Restricted to one core, the 48-channel model still reaches 0.8. DCCRN-E takes 3.12 ms per frame on an Intel i5-8250U, an RTF of 0.5 at its 6.25 ms hop. RNNoise uses 14% of one core of a 1.2 GHz ARM Cortex-A53, so an RTF of 0.14 at 10 ms, about 1.4 ms per frame.
Average compute time is not the number to watch. The worst frame is. Operating systems pause your thread for other jobs, caches go cold, a background app wakes up. A model with an average RTF of 0.6 may still need 1.5 hops on one unlucky frame. That frame is late, and a late frame is an audible glitch. Symptom: periodic clicks that grow when the robot also runs vision. Measurement: the worst-case or 99th percentile response time, not the mean. Fix: smaller model, quantized weights, a larger hop, or a dedicated core.
Each bar is how long one frame waited from arrival until its cleaned output was ready. The dashed line is the deadline, one hop. Pick a model, then slow the chip down or switch on background load.
Compute times are from the papers, on the machine each paper names: RNNoise 14% of a Cortex-A53 core (Valin 2018), DCCRN-E 3.12 ms per frame on an i5-8250U (Hu et al. 2020), Demucs RTF 0.6 and 1.05 on a quad-core 2.0 GHz i5 (Défossez et al. 2020). A chip speed of 1× means that machine. Illustrative: every frame varies by up to 8%, and background load makes every seventh frame cost 2.4 times as much. Late frames queue behind each other, as a real audio thread does.
A file-based model takes a whole recording and returns a whole recording. A streaming model keeps state between calls. The overlap buffer holds the second half of the last window. The GRU or LSTM keeps its hidden vector. The noise estimate keeps its running average. The echo canceller keeps its taps. Break the state, for example by processing blocks of different sizes in a different order, and the output differs from the file version. The Demucs streaming code keeps a small buffer of past input and output to limit edge effects of its resampling filters, and it notes that the rightmost part of each output is invalid because it needs future audio.
pythonclass Stream: def __init__(self, model, hop=480): self.model, self.hop = model, hop self.tail = np.zeros(hop) # overlap buffer: second half of the last window self.h = model.init_state() # GRU hidden vectors live here def push(self, block): # block: [hop] new samples from the mic win = np.concatenate([self.tail, block]) # [2*hop] gains, self.h = self.model.step(win, self.h) # one frame, state carried over out = overlap_add(win, gains) # [hop] clean samples self.tail = block return out # must be ready before the next block arrives
On a robot with a loudspeaker the order matters. Echo cancellation goes first, because the echo path is linear and the canceller relies on that. A neural noise suppressor is not linear, and running it first would distort the echo in ways the canceller cannot model. After the canceller comes the noise suppressor, and then, if the recogniser needs it, dereverberation. Motors add ego-noise that is loud and highly predictable. The robot can feed its own motor commands in as a reference, just as the echo canceller uses the far-end signal.
Size matters beyond speed. RNNoise’s 87,503 weights can be stored in 8 bits with no loss, so they fit in a CPU’s L2 cache. A 12.5-million-weight network of the same era needs around 800 MB/s of memory bandwidth even at 8 bits. Memory is the tight budget on small chips, so counting weights is as important as counting multiplications.
Chapter 10
Keep the numbers, the checks and the core code in one place, and follow the links to the papers behind every claim
This lesson followed one thread. A recording becomes a grid. A cleaner chooses a gain for each cell: first by subtracting a noise average, then by trusting each cell by its cleanliness, then by learning the answer key from mixtures it built itself. Echo is cancelled with a signal the robot already has. Reverb is predicted from earlier frames. Every result is scored by several metrics that measure different things, and everything runs under a deadline measured in milliseconds.
| Term or number | Meaning | Where from |
|---|---|---|
| 6 dB per doubling | A voice loses about 6 dB of level each time the distance doubles; room noise does not move. | Free-field rule; chapter 0 |
| Bin spacing fs / N | N samples at fs Hz give bins fs / N apart: 31.25 Hz for N = 512 at 16 kHz. | Chapter 1 |
| G = √(1 − αN̂2/|Y|2) | Spectral subtraction gain, with a floor; leaves musical noise. | Boll 1979 |
| G = ξ / (1 + ξ) | Wiener gain; ξ = 1 gives 0.5, or −6 dB. | Derived in chapter 3 |
| IRM, β = 0.5 | Ideal ratio mask, √(S2/(S2+N2)). | Wang et al. 2014 |
| RNNoise | 48 kHz, 20 ms window, 10 ms hop, 22 bands, 42 features, GRUs of 24, 48, 96 units, 87,503 weights, about 40 million operations per second. | Valin 2018 |
| RNNoise cost | 1.3% of one Haswell i7 core; 14% of one 1.2 GHz Cortex-A53 core. | Valin 2018 |
| DCCRN | 3.7 million parameters; 25 ms window, 6.25 ms hop; 37.5 ms look-ahead; 3.12 ms per frame on an i5-8250U; first in the real-time track of the 2020 DNS challenge by MOS. | Hu et al. 2020 |
| Causal Demucs | 37 ms frame, 16 ms stride, 3 ms look-ahead; RTF 0.6 (48 channels) and 1.05 (64) on a quad-core i5; Valentini PESQ 2.93, STOI 95. | Défossez et al. 2020 |
| DeepFilterNet | 32 ERB gains, then a deep filter of order 5 up to 5 kHz; 1.8 million parameters; 0.35 billion MACs per second; WB-PESQ 2.81; 5 ms minimum latency at a 5 ms window. | Schröter et al. 2022 |
| NLMS echo canceller | 12 ms (96 taps) or 32 ms (256 taps) at 8 kHz, plus a non-linear processor for the residue. | TI AIC3254 note |
| DNSMOS vs listeners | Pearson 0.93; PESQ 0.78; POLQA 0.79; SDR 0.23. | Reddy et al. |
| RTF = tcompute / thop | Must be below 1; watch the slowest frame, not the mean. | Chapter 9 |
This is the whole of chapters 1 to 3 in one function, followed by the echo canceller of chapter 7. It is a teaching sketch, short on purpose: it runs offline on a whole array, and the streaming version keeps the same state between blocks.
pythonimport numpy as np def wiener_denoise(x, n=512, hop=256, silent_frames=6, a=0.7, floor=10**(-25/10)): w = np.hanning(n) # chapter 1: window starts = range(0, len(x) - n + 1, hop) Y = np.stack([np.fft.rfft(w * x[s:s+n]) for s in starts]) # [frames, n//2+1] complex P = np.abs(Y) ** 2 Nh = P[:silent_frames].mean(axis=0) # chapter 2: noise power per bin out = np.zeros(len(x)); prev = np.zeros_like(Nh) for t, s in enumerate(starts): ml = np.maximum(P[t] / Nh - 1, 0) # raw cleanliness guess xi = np.maximum(a * prev / Nh + (1 - a) * ml, floor) # chapter 3: decision-directed G = xi / (1 + xi) # Wiener gain per bin prev = (G ** 2) * P[t] out[s:s+n] += np.fft.irfft(G * Y[t], n) * w # synthesis + overlap-add (windows sum to a constant) return out / 1.5 # Hann at 50% overlap: squared windows sum to 1.5 def nlms_echo(far, mic, taps=64, mu=0.5, eps=1e-3): # chapter 7 w = np.zeros(taps); e = np.zeros(len(mic)) for n in range(taps, len(mic)): xv = far[n-taps+1:n+1][::-1] # latest far-end samples first e[n] = mic[n] - w @ xv # error = cleaned output w += mu * e[n] * xv / (xv @ xv + eps) # normalised step return e
Single-microphone enhancement, the subject of this lesson, is one stage of a robot’s hearing. Microphone arrays add direction: they listen toward the talker and null other directions, and neural cleaners can then be applied after the array. Speech models downstream can also be trained on noisy audio so that less enhancement is needed. Whether to enhance before a recogniser or to train the recogniser on noisy speech is a real design choice, and the Demucs paper includes a study of exactly this effect on recognition.
The arXiv papers and the Texas Instruments note were read in full for this lesson. The classic papers and the ITU recommendations are cited by their published details. Numbers in the chapters come from the papers named in each device’s fine print. No course slides were used.
Now press Present or Teach and explain one frame of cleaning out loud, from memory: how the grid is made, why subtraction sings, what the Wiener gain is at equal speech and noise, what a network learns, how an echo canceller finds the path, and which number tells you the device will keep up. Then go back to the sound grid at the top, switch on the door slam, and say which of the four cleaners fails and why.