---
title: "Remove Background Noise from a Call with RNNoise in Node.js | Micdrop"
description: "Clean the audio of a phone call or any stream on a Micdrop server with RNNoise in WebAssembly, before turn detection and speech to text, or plug your own audio filter."
url: "https://micdrop.dev/docs/server/audio-filters"
---

# Remove Background Noise from a Call with RNNoise in Node.js

A browser removes the noise of the room before the audio leaves the page. A phone line does not: the caller’s street, car or open space reaches the server as it was captured, and the voice activity detection hears speech in it, the speech to text writes words that nobody said, and the agent answers them.

`@micdrop/rnnoise` cleans that audio on the server with [RNNoise](https://github.com/xiph/rnnoise), the noise suppression network of Xiph.Org, compiled to WebAssembly. It runs in the Node process, with no native module and no service to call, before anything else hears the user.

```bash
npm install @micdrop/rnnoise
```

```typescript
import { MicdropServer, waitForParams } from '@micdrop/server'
import { RnnoiseFilter, loadRnnoise } from '@micdrop/rnnoise'
import { TwilioTransport } from '@micdrop/telephony'
import '@micdrop/silero/node'

// Compiles RNNoise once, when the server starts
await loadRnnoise()

app.get('/phone', { websocket: true }, async (socket) => {
  const transport = new TwilioTransport(socket)
  await waitForParams(transport, (value) => value)

  new MicdropServer(transport, {
    turns: { vad: 'silero' },
    audioFilters: [new RnnoiseFilter()],
    agent,
    stt,
    tts,
  })
})
```

Each call gets its own `RnnoiseFilter`, since it learns the noise of its line. The server destroys it when the call ends. The [RNNoise tutorial](/blog/rnnoise-noise-suppression-nodejs) builds a complete Twilio agent with it.

## Where the filters run

`audioFilters` runs on the audio the transport receives, one filter after the other, before everything that listens to the user:

1.  the [server VAD](/docs/server/vad) and the [semantic turn detection](/docs/server/semantic-turn-detection), which stop hearing speech in a passing truck;
2.  the speech to text, or the realtime model;
3.  the `UserAudio` event, and so the [recordings](/docs/server/recording-audio).

It works with every transport: [phone calls](/docs/transports/telephony), [WebRTC](/docs/transports/webrtc) and WebSocket clients alike. A browser client already suppresses noise, so the filter matters most where the audio comes from a phone line or a device without that processing.

A call without `audioFilters` runs no filter code at all.

## What it costs

Measured on an Apple M2 with Node 24, on a voice mixed with white noise:

Line

CPU per second of audio

Delay

8 kHz (Twilio, Telnyx, Plivo)

about 15 ms

about 22 ms

16 kHz (Vonage, browser)

about 18 ms

about 22 ms

48 kHz

about 13 ms

20 ms

One core filters about 50 calls at once. RNNoise works on 10 ms frames at 48 kHz, so the filter brings the line to 48 kHz and back, which accounts for the difference between the rates. Each call holds about 75 KB of memory, and the 1.4 MB model is loaded once for the whole process.

On that test signal, the noise alone drops by more than 60 dB, and the voice comes out at the level it had before the noise was added. Real noise is harder than white noise: RNNoise removes steady sounds well (fans, traffic, hum, a car), and lets more of the sudden ones through (a door, a dog, a voice in the background).

## Options

Option

Type

Default

Description

`strength`

`number`

`1`

How much of the denoised audio to keep, from `0` (the audio as received) to `1` (fully denoised)

`wasm`

`WebAssembly.Module`, `ArrayBuffer` or `Uint8Array`

the file of the package

The compiled RNNoise, for a runtime that cannot read it from disk

Some speech to text models are trained on noisy audio and transcribe better with a little of it left. If transcripts get worse with the filter, try a `strength` of `0.7` before removing it.

`filter.voiceProbability` holds how likely the last frame held a voice, from `0` to `1`, as RNNoise estimates it.

## Load it at startup

A `RnnoiseFilter` created before RNNoise is compiled holds the first chunks of its call until it is ready, a few milliseconds. `await loadRnnoise()` when the server starts makes every filter ready from the first chunk, and makes a broken install fail at startup instead of during a call.

## Write your own filter

An audio filter is any object with a `process` method. It receives mono samples in the range from -1 to 1 with their sample rate, and returns the filtered samples at the same rate:

```typescript
import type { AudioFilter } from '@micdrop/server'

class Gain implements AudioFilter {
  constructor(private readonly factor: number) {}

  process(frames: Float32Array, sampleRate: number) {
    return frames.map((sample) => sample * this.factor)
  }
}

new MicdropServer(transport, {
  audioFilters: [new RnnoiseFilter(), new Gain(1.5)],
  // ...
})
```

*   A filter that works on fixed frames may hold samples back and return fewer than it received, or none, as long as its delay stays the same all along.
*   `process` may return a promise, for a filter that calls a worker or a native SDK asynchronously. Chunks keep their order behind it, and a filter that answers synchronously costs no extra tick.
*   `reset()` forgets the audio held back, and `destroy()` frees what the filter holds. Both are optional, and the server calls `destroy()` when the call ends.
*   A filter that throws is logged, and the chunk goes on unfiltered, so the call keeps its audio.

The interface is structural: a package that wraps a commercial noise suppression SDK can implement it without depending on Micdrop.

## On the client

The same filters run on the microphone of a client, before its VAD and before the audio leaves the device, with `Mic.setFilters()`:

```typescript
import { Mic } from '@micdrop/client'

Mic.setFilters([myFilter])
```

A browser has noise suppression of its own, so this is for a platform that lacks it, with a filter that runs there: a native module on React Native, whose JavaScript engine has no WebAssembly. A WebRTC transport sends the media stream as the system records it, without these filters.

## Not to be confused with filler sounds

This page removes the noise under the voice. A user who says “hmm” or coughs still produces a turn, which the agent can drop with [`ignoreNoiseTool()`](/docs/server/noise-filtering). The two work together.
