---
title: "RNNoise in Node.js: Remove Background Noise from Phone Calls"
description: "A phone line brings the street, the car and the open space of the caller to your server. Clean that audio in Node.js with RNNoise in WebAssembly, before turn detection and speech to text hear it, in a few lines of TypeScript."
url: "https://micdrop.dev/blog/rnnoise-noise-suppression-nodejs"
---

# RNNoise noise suppression in Node.js for an AI phone agent

A phone line brings the street, the car and the open space of the caller to your server. Clean that audio in Node.js with RNNoise in WebAssembly, before turn detection and speech to text hear it, in a few lines of TypeScript.

November 29, 2026

[Godefroy de Compreignac](https://github.com/Godefroy)

Key takeaways

*   A browser removes the noise of the room before the audio leaves the page. A phone line brings it to your server untouched, where it opens false turns and puts words in the transcript.
*   RNNoise is a small neural network by Xiph.Org that runs on 10 ms frames. Compiled to WebAssembly, it runs inside the Node process with no native module and no service to call.
*   With Micdrop, one line adds it to a call: \`audioFilters: \[new RnnoiseFilter()\]\`. It runs before the VAD, the turn detector, the speech to text and the recordings.
*   Measured on an Apple M2, it costs about 15 ms of CPU per second of an 8 kHz phone call and adds about 22 ms of delay, so one core filters about 50 calls at once.
*   RNNoise removes steady noise well (fans, traffic, a car, hum) and lets more of the sudden sounds through. A speech to text trained on noisy audio may prefer a partial strength.

A caller on a phone line is rarely in a quiet room. They walk down a street, drive with the window open, sit in an open space or next to a fan. A browser call would have cleaned that up before the audio left the page, since `getUserMedia` applies the noise suppression of the system by default. A phone call reaches your server as the handset captured it.

For a voice agent, that noise costs more than comfort. The voice activity detection hears speech in a passing truck and opens a turn. The speech to text writes a word nobody said. The agent answers it, and the caller hears the assistant talk over them for no reason.

This tutorial removes that noise on the server, in Node.js, with [RNNoise](https://github.com/xiph/rnnoise) compiled to WebAssembly, and plugs it into an AI phone agent built with [Micdrop](/), the open source TypeScript library this site publishes.

## What RNNoise is

RNNoise is a noise suppression library by Xiph.Org, the foundation behind Opus and FLAC. It mixes classic signal processing with a small recurrent neural network: the network estimates, band by band, how much of each 10 ms frame is voice, and the library attenuates the rest. The model weighs about 1.4 MB and runs comfortably on a CPU, which is why it shows up in so many voice products.

`@micdrop/rnnoise` ships RNNoise compiled to WebAssembly, with a resampler around it. It runs in the Node process itself: no native module to build, no Python, no service to call per frame.

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

## Why phone calls need it on the server

Noise suppression belongs as close to the microphone as possible. In a web app that is the browser, and the [Micdrop client](/docs/client) already asks for it. On a phone call, nobody on your side touches the audio before the provider streams it to your WebSocket, and many handsets and lines leave the background in.

The order of the steps matters too. Filtering the audio after the speech to text would come too late: the false turn would already be open. A server filter has to sit at the very start of the chain, where the transport hands over the audio of the caller.

## Add RNNoise to a call

`MicdropServer` takes an `audioFilters` option, a list of filters applied in order to the audio of the user. `RnnoiseFilter` is one of them:

```typescript
import { MicdropServer } from '@micdrop/server'
import { loadRnnoise, RnnoiseFilter } from '@micdrop/rnnoise'

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

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

Each call gets its own `RnnoiseFilter`, because the network keeps a state that learns the noise of that line. The server destroys it when the call ends.

`loadRnnoise()` is optional but worth it. A filter created before RNNoise is compiled holds the first chunks of its call for the few milliseconds it takes, and a broken install would only show during a call. Awaiting it at startup makes every filter ready from the first chunk, and makes a missing file fail when the process starts.

## Where the filter runs

The filters run on the audio the transport receives, before everything that listens to the user:

```mermaid
graph LR
  A[Phone line] --> B[Transport]
  B --> C[RnnoiseFilter]
  C --> D[Silero VAD and turn detector]
  C --> E[Speech to text or realtime model]
  C --> F[UserAudio event and recordings]
```

1.  The [server VAD](/docs/server/vad) and the [semantic turn detection](/docs/server/semantic-turn-detection) hear a cleaner signal, so a truck or a door opens fewer turns.
2.  The speech to text, or the realtime model, receives the denoised audio.
3.  The `UserAudio` event, and so the [recordings](/docs/server/recording-audio), carry the cleaned voice too.

The filter works with every transport: the [phone transports](/docs/transports/telephony) of Twilio, Vonage, Telnyx and Plivo, [WebRTC](/docs/transports/webrtc) and the WebSocket clients alike. A call without `audioFilters` runs no filter code at all.

## A complete phone agent with noise suppression

The server below answers a Twilio number, checks that Twilio signed each request, and runs every call through RNNoise. It extends the [Twilio phone agent tutorial](/blog/ai-phone-agent-twilio-node), which explains the TwiML and the Media Stream step by step.

```bash
mkdir phone-agent && cd phone-agent
npm init -y
npm pkg set type=module
npm install @micdrop/server @micdrop/telephony @micdrop/openai @micdrop/silero @micdrop/rnnoise onnxruntime-node ws
npm install -D tsx typescript @types/node @types/ws
```

`server.ts`

```typescript
import { createServer } from 'node:http'
import { OpenaiAgent, OpenaiSTT, OpenaiTTS } from '@micdrop/openai'
import { loadRnnoise, RnnoiseFilter } from '@micdrop/rnnoise'
import { endCallTool, MicdropServer, waitForParams } from '@micdrop/server'
import {
  twilioStreamTwiml,
  TwilioTransport,
  validateTwilioSignature,
} from '@micdrop/telephony'
import { WebSocket, WebSocketServer } from 'ws'
// Loads Silero, which finds the turns of the caller on the server
import '@micdrop/silero/node'

const PORT = 8102
const host = process.env.PUBLIC_HOST || `localhost:${PORT}`
const apiKey = process.env.OPENAI_API_KEY || ''
const authToken = process.env.TWILIO_AUTH_TOKEN || ''

// Compiles the noise suppression once, before the first call
await loadRnnoise()

// Twilio asks what to do with an incoming call
const http = createServer(async (request, response) => {
  if (request.url !== '/twilio/voice') return response.writeHead(404).end()

  let body = ''
  for await (const chunk of request) body += chunk

  const signed = validateTwilioSignature({
    authToken,
    signature: request.headers['x-twilio-signature'] as string | undefined,
    url: `https://${host}${request.url}`,
    params: new URLSearchParams(body),
  })
  if (!signed) return response.writeHead(403).end()

  response.writeHead(200, { 'Content-Type': 'text/xml' })
  response.end(twilioStreamTwiml({ url: `wss://${host}/twilio/stream` }))
})

// Twilio streams the call to this WebSocket, with a signed opening
const wss = new WebSocketServer({ noServer: true })
http.on('upgrade', (request, socket, head) => {
  const signed =
    request.url === '/twilio/stream' &&
    validateTwilioSignature({
      authToken,
      signature: request.headers['x-twilio-signature'] as string | undefined,
      url: `wss://${host}${request.url}`,
    })
  if (!signed) return socket.destroy()
  wss.handleUpgrade(request, socket, head, (ws) => runCall(ws))
})

async function runCall(socket: WebSocket) {
  const transport = new TwilioTransport(socket)
  await waitForParams(transport, (params) => params)

  const server = new MicdropServer(transport, {
    // A phone line has no client to find the turns: the server listens
    turns: { vad: 'silero' },
    // Removes the noise around the caller before the VAD and the STT hear it
    audioFilters: [new RnnoiseFilter()],
    firstMessage: 'Hello, thanks for calling. How can I help you?',
    agent: new OpenaiAgent({
      apiKey,
      systemPrompt:
        'You answer the phone for a small company. Your answers are spoken on a phone line, so keep them short and conversational.',
      tools: [endCallTool()],
    }),
    stt: new OpenaiSTT({ apiKey, language: 'en' }),
    tts: new OpenaiTTS({ apiKey, voice: 'alloy' }),
  })

  server.on('End', ({ duration }) => console.log(`Call ended after ${duration} s`))
}

http.listen(PORT, () => console.log(`Listening on http://localhost:${PORT}`))
```

Start a tunnel to port 8102, set the voice webhook of your Twilio number to `https://<your host>/twilio/voice` with the POST method, and run:

```bash
PUBLIC_HOST=abcd.ngrok.app OPENAI_API_KEY=sk-... TWILIO_AUTH_TOKEN=... npx tsx server.ts
```

Call the number from a noisy place, then comment out the `audioFilters` line and call again: the difference shows in the transcript and in how often the assistant starts answering a noise.

## What it costs in CPU and delay

The Micdrop documentation measured the filter 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

RNNoise works on 10 ms frames at 48 kHz, so the filter brings a phone line up to 48 kHz and back down, which explains why 48 kHz costs the least. One core filters about 50 calls at once. Each call holds about 75 KB, and the model is loaded once for the whole process.

On that test signal the noise alone drops by more than 60 dB, while the voice keeps the level it had before the noise was added. Real noise is harder than white noise. RNNoise does best on steady sounds (fans, traffic, a car, the hum of a line) and lets more of the sudden ones through (a door, a dog, a voice in the background).

Twenty milliseconds of delay sits well inside what a phone call already adds: the network of the provider puts 100 to 200 ms on top of a browser call.

## Tune the strength

Some speech to text models are trained on noisy audio and transcribe better when a little of it remains. `strength` sets how much of the denoised audio the filter keeps, from `0`, the audio as received, to `1`, fully denoised:

```typescript
audioFilters: [new RnnoiseFilter({ strength: 0.7 })]
```

If your transcripts get worse with the filter, try `0.7` before removing it, and compare on real recordings of your callers rather than on a test file.

The filter also exposes how likely the last frame held a voice, as RNNoise estimates it, from `0` to `1`:

```typescript
const rnnoise = new RnnoiseFilter()
// ...
console.log(rnnoise.voiceProbability)
```

Turn detection keeps using Silero, which is the better judge of speech, but the value helps when you log the quality of a line.

## Write your own filter

An audio filter is any object with a `process` method. It receives mono samples between -1 and 1 with their sample rate, and returns the filtered samples at the same rate. The `AudioFilter` type comes from `@micdrop/server`:

```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, as RNNoise does, as long as its delay stays constant. `process` may return a promise, for a filter that calls a worker or a native SDK. A filter that throws is logged, and the chunk goes on unfiltered, so the call keeps its audio. Since the interface is structural, a wrapper around a commercial noise suppression SDK can implement it without depending on Micdrop.

## Noise under the voice, and noise instead of a sentence

Two different problems share the word noise in a voice agent:

*   **Background noise under the voice of the caller**, which RNNoise removes from the signal.
*   **A turn that holds no sentence**, a lone “hmm” or a cough that the speech to text wrote down as a word. The agent can drop that turn with [`ignoreNoiseTool()`](/docs/server/noise-filtering), which lets the model stay silent instead of asking the caller to repeat.

They work together. RNNoise keeps most noises from opening a turn at all, and the tool catches the filler words that still get through.

## Frequently asked questions

### Can RNNoise run in Node.js without a native module?

Yes. `@micdrop/rnnoise` ships RNNoise compiled to WebAssembly, which Node runs out of the box. There is nothing to compile on install and no platform specific binary, so the same package runs on macOS, Linux and in a container.

### Does RNNoise work on 8 kHz phone audio?

Yes. RNNoise itself works at 48 kHz, and the filter resamples a phone line to 48 kHz and back around it. The Micdrop documentation measures about 15 ms of CPU per second of an 8 kHz call, and about 22 ms of delay.

### Should I denoise browser calls too?

Usually no. The browser applies the noise suppression of the system to the microphone before the audio leaves the page. A server filter matters most for phone lines, and for devices or apps that skip that processing.

### Will noise suppression hurt my speech to text?

It can, with models trained on noisy audio. Lower `strength` to keep part of the original signal, and compare transcripts of real calls with and without the filter before you settle.

### Does it work with a speech to speech model?

Yes. The filters run before the realtime model as they run before the speech to text, so OpenAI Realtime, Gemini Live or Grok Voice hear the cleaned audio.

## Going further

The [noise suppression documentation](/docs/server/audio-filters) lists every option and the filters on the client. The [telephony documentation](/docs/transports/telephony) covers the four phone providers, and the [sample rate guide](/blog/audio-sample-rate-voice-agent) explains what an 8 kHz line does to a voice agent.

## Keep reading

[

November 29, 2026

## Build an AI Phone Agent in Node.js with Twilio

Answer a Twilio phone number with an AI voice agent running in your own Node.js server: TwiML, Media Streams, turn detection, tools and hang up, in one TypeScript file.



](/blog/ai-phone-agent-twilio-node)

[![Audio Sampling Rate in a Voice Agent: 16, 24 or 48 kHz](/_astro/thumbnail.9EkTb0B-_Z1KtFVX.webp)

October 14, 2026

## Audio Sampling Rate in a Voice Agent: 16, 24 or 48 kHz

Browsers record at 44.1 or 48 kHz, speech models read 16 kHz and many voices speak at 24 kHz. Learn the rate each stage expects and what resampling costs.



](/blog/audio-sample-rate-voice-agent)

[![Voice Activity Detection in the Browser: Silero vs WebRTC](/_astro/thumbnail.BUmw0JPI_cI8C7.webp)

August 13, 2026

## Voice Activity Detection in the Browser: Silero vs WebRTC

A browser voice agent needs voice activity detection to tell when the user speaks. Compare volume thresholds, WebRTC VAD and Silero, then tune your choice.



](/blog/voice-activity-detection-browser)
