---
title: "Silero VAD in the Browser: A Step by Step TypeScript Tutorial"
description: "Detect speech in a web page with Silero VAD and TypeScript: a speaking indicator, speech only recording, tuning for noise, then a full voice conversation."
url: "https://micdrop.dev/blog/silero-vad-browser"
---

# Run Silero VAD in the browser, step by step

Detect speech in a web page with Silero VAD and TypeScript: a speaking indicator, speech only recording, tuning for noise, then a full voice conversation.

November 29, 2026

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

Key takeaways

*   Silero VAD is a two megabyte neural network that gives each 32 ms of audio a probability of speech. ONNX Runtime Web runs it in any modern browser, on the user's device.
*   With @micdrop/web, a speaking indicator takes about ten lines of TypeScript, and the same recorder hands you 100 ms chunks of speech only, silences left out.
*   Serve the model and the ONNX runtime from your own domain, with the Vite plugin or two options, so a CDN outage or an ad blocker cannot break detection.
*   Silero hears that someone stopped speaking. Pair it with Smart Turn to know whether they finished their sentence.

Voice activity detection tells a web page when someone is speaking. It drives the speaking indicator of a call, decides which audio is worth sending to a speech to text service, and lets a user cut an AI assistant off by talking over it. [Silero VAD](https://github.com/snakers4/silero-vad) is the open model most voice products use for it, because it tells a voice from a fan, a keyboard or a television where a volume threshold cannot.

This tutorial runs Silero VAD in the browser with TypeScript, in four steps: a speaking indicator, speech only recording, tuning for noise, and finally a voice conversation with an AI agent. It uses `@micdrop/web`, the browser package of [Micdrop](/), which wraps the model, its runtime and the speech logic. Each step builds on the previous one, and you can stop at the one you need.

If you are still choosing a detector, the [comparison of Silero, WebRTC VAD and a volume threshold](/blog/voice-activity-detection-browser) explains when each one wins.

## How Silero VAD runs in a browser

Silero VAD is a small recurrent network that the Silero team trained on a large corpus of speech and noise in many languages, released under the MIT license. Its ONNX export weighs about two megabytes. It reads audio at 16 kHz in windows of 512 samples, 32 ms each, and answers each window with a probability of speech between 0 and 1.

In a browser, [ONNX Runtime Web](https://onnxruntime.ai/docs/tutorials/web/) runs the model in WebAssembly, on the user’s own device. A window takes well under a millisecond, so the model keeps up with the microphone on any recent laptop or phone, and no audio has to leave the page to be classified.

A probability per window is not yet a speaking indicator. Something has to decide that a few windows above a threshold mean speech has started, and that enough windows below another threshold mean it has stopped. Micdrop does this with the same algorithm as [ricky0123/vad](https://github.com/ricky0123/vad), the open source project that first ran Silero in the browser, and adds a reserve of recent audio so the first syllable is never cut.

## Step 1: a speaking indicator

Start from any web project. With Vite:

```bash
npm create vite@latest silero-demo -- --template vanilla-ts
cd silero-demo
npm install @micdrop/web onnxruntime-web
```

Add the Micdrop plugin to `vite.config.ts`. It ships the model and the ONNX runtime files with your build, so the page never fetches them from a CDN:

`vite.config.ts`

```typescript
import { micdrop } from '@micdrop/web/vite'
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [micdrop()],
})
```

Then replace `src/main.ts`:

`src/main.ts`

```typescript
import { Mic, MicRecorder } from '@micdrop/web'
// Registers the Silero model and its ONNX runtime
import '@micdrop/web/silero'

const button = document.createElement('button')
button.textContent = 'Start listening'
document.body.append(button)

button.onclick = async () => {
  await Mic.start()
  const recorder = new MicRecorder('silero')
  await recorder.start(Mic)

  recorder.on('StartSpeaking', () => (document.body.style.background = '#16a34a'))
  recorder.on('StopSpeaking', () => (document.body.style.background = ''))
  button.textContent = 'Listening, say something'
}
```

Run `npm run dev`, open the page and click the button. The browser asks for the microphone, the model loads, and the page turns green while you speak. Type on your keyboard or play music next to it, and it stays white.

The microphone only starts after a click because browsers require a user gesture to capture audio, and only on a secure page, served over HTTPS or from `localhost`.

## Step 2: record speech only

The recorder does more than detect speech. Its `Chunk` event hands you the audio of each turn as it is spoken, 100 ms at a time, mono PCM at 16 kHz, starting a little before the detector confirmed speech so the first word is whole. Silences never produce chunks:

```typescript
const chunks: Int16Array[] = []

recorder.on('StartSpeaking', () => (chunks.length = 0))
recorder.on('Chunk', (chunk) => chunks.push(chunk))
recorder.on('StopSpeaking', () => {
  // One utterance, ready for a speech to text API of your choice
  sendToTranscription(chunks)
})
```

That is the most common use of a VAD outside a conversation: send a speech to text service only what was said, and pay for nothing else.

## Step 3: tune it for your users

The defaults suit a voice agent with turn detection, and two thresholds move everything else. Pass a `SileroVAD` instance instead of the `'silero'` name to set them:

```typescript
import { MicRecorder, SileroVAD } from '@micdrop/web'

const recorder = new MicRecorder(
  new SileroVAD({
    positiveSpeechThreshold: 0.18, // Probability that counts as speech
    negativeSpeechThreshold: 0.11, // Probability that counts as silence
    minSpeechFrames: 4, // Windows of speech before the turn starts
    redemptionFrames: 8, // Windows of silence before the turn ends
  })
)
```

*   Users in a noisy place trigger it too often: raise `positiveSpeechThreshold` and `minSpeechFrames`.
*   Soft voices are missed: lower `positiveSpeechThreshold`.
*   Speech is cut during short pauses: raise `redemptionFrames`, twenty windows being about 640 ms. Step 4 shows a better answer with Smart Turn.

To ignore a colleague talking in the background, combine Silero with a volume threshold, `new MicRecorder(['volume', 'silero'])`. A turn then starts only when the sound is a voice and loud enough to be the user’s.

Settings passed by name are saved in `localStorage`, so a settings screen can change them with `recorder.vad.setOptions()` and keep them across visits. The [VAD documentation](/docs/client/vad) lists every option and event.

## Step 4: a voice conversation

The same detector drives a full conversation with an AI agent. The browser sends audio only while the user speaks, and a Node server transcribes it, writes the answer and speaks it back:

`src/main.ts`

```typescript
import { Micdrop } from '@micdrop/web'
import '@micdrop/web/silero'

button.onclick = () => Micdrop.start({ url: 'ws://localhost:8081', vad: 'silero' })

Micdrop.on('StateChange', (state) => {
  document.body.style.background = state.isUserSpeaking ? '#16a34a' : ''
})
```

On the server:

```bash
npm install @micdrop/server @micdrop/openai ws
```

`server.ts`

```typescript
import { OpenaiAgent, OpenaiSTT, OpenaiTTS } from '@micdrop/openai'
import { MicdropServer } from '@micdrop/server'
import { WebSocketServer } from 'ws'

const apiKey = process.env.OPENAI_API_KEY || ''

new WebSocketServer({ port: 8081 }).on('connection', (socket) => {
  new MicdropServer(socket, {
    firstMessage: 'Hi! What can I do for you?',
    agent: new OpenaiAgent({ apiKey, systemPrompt: 'You are a helpful assistant.' }),
    stt: new OpenaiSTT({ apiKey }),
    tts: new OpenaiTTS({ apiKey }),
  })
})
```

The client also handles what a conversation adds on top of the VAD: the assistant’s voice played back, echo cancellation so the assistant does not hear itself, and interruptions when the user talks over it.

A VAD hears that the user went quiet, which also happens when they pause to think. [Smart Turn](/blog/smart-turn-javascript) listens to the end of the sentence and keeps the turn open while it sounds unfinished, so you can keep the short `redemptionFrames` that make the agent answer quickly.

## Without Vite

With another bundler, serve the model and the two ONNX runtime files (`ort-wasm-simd-threaded.jsep.mjs` and `ort-wasm-simd-threaded.jsep.wasm`, from `onnxruntime-web/dist`) from your own domain, and tell Micdrop where they are:

```typescript
import { setSileroOptions } from '@micdrop/web/silero'

setSileroOptions({
  model: '/assets/silero_vad_v5.onnx',
  wasmPath: '/assets/onnxruntime/',
})
```

Left alone, Micdrop fetches them from jsDelivr and unpkg on the first call. That works for a prototype, and fails wherever those CDNs are blocked.

## Silero VAD on a phone and on a server

The same `MicRecorder` and the same model run in a [React Native app](/docs/react-native/vad), on the native ONNX runtime, and on a [Node.js server](/docs/server/vad) with `@micdrop/silero` and `onnxruntime-node`. The server side matters for phone calls, where no app on the line can run the detector, as the [Twilio phone agent tutorial](/blog/ai-phone-agent-twilio-node) shows.

## Frequently asked questions

### How do I use Silero VAD in JavaScript?

Install `@micdrop/web`, import `@micdrop/web/silero` to register the model, then create a `MicRecorder('silero')` on the microphone. It emits `StartSpeaking` and `StopSpeaking`, and `Chunk` events carrying the audio of each utterance.

### Does Silero VAD send audio to a server?

No. The model runs in the page, on ONNX Runtime Web, so the audio is classified on the user’s device. Only what your own code sends, such as the speech chunks of a conversation, leaves the browser.

### Which browsers can run Silero VAD?

Any browser with WebAssembly and the Web Audio API, which covers Chrome, Edge, Firefox and Safari on desktop and mobile. The microphone requires a secure page, served over HTTPS or from localhost.

### How much latency does Silero VAD add?

Scoring a 32 ms window takes well under a millisecond. Confirming speech takes a few windows, four by default, and Micdrop keeps that audio in reserve so it is sent with the turn rather than lost.

### Is Silero VAD free for commercial use?

Yes. The model is released under the MIT license, and so is Micdrop.

## Getting started

The [VAD documentation](/docs/client/vad) covers every option, the combined detectors and custom VADs, and [Getting Started](/docs/getting-started) sets up a complete voice conversation in five minutes.

## Keep reading

[![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)

[

November 29, 2026

## Smart Turn in JavaScript: End of Turn Detection Tutorial

Run the open Smart Turn v3 model in the browser and in Node.js with TypeScript, on its own or inside a voice agent, so the agent waits through hesitations and answers finished sentences fast.



](/blog/smart-turn-javascript)

[![Acoustic Echo Cancellation in the Browser](/_astro/thumbnail.CGcUswH3_ZJSHgC.webp)

October 31, 2026

## Acoustic Echo Cancellation in the Browser

Browser echo cancellation reduces speaker audio in microphone input. Learn how getUserMedia requests it, check settings and handle remaining echo.



](/blog/echo-cancellation-browser-voice-agent)
