npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@aid-on/vad

v0.1.3

Published

Silero VAD wrapper for browser - voice activity detection

Readme

@aid-on/vad

npm version TypeScript License: MIT

日本語 | English

Why @aid-on/vad?

Building voice-driven browser applications means solving two hard problems: detecting when the user is actually speaking, and filtering out background noise before processing. This package solves both:

  • Silero VAD - State-of-the-art speech detection model via ONNX Runtime
  • RNNoise suppression - Optional noise reduction pipeline using WebAssembly
  • Simple callback API - onSpeechStart, onSpeechEnd, onFrameProcessed, onVADMisfire
  • WAV conversion - Built-in audioToWav() for sending captured audio to STT APIs
  • Auto CDN versioning - Pinned, tested versions of vad-web and ONNX Runtime loaded from CDN
  • Zero configuration - Sensible defaults, start detecting speech in 5 lines of code

Installation

npm install @aid-on/vad

Note: This package is browser-only. It requires WebAssembly support and access to navigator.mediaDevices.getUserMedia.

Quick Start

import { createVAD } from "@aid-on/vad";

const vad = await createVAD({
  onSpeechStart: () => {
    console.log("User started speaking");
  },
  onSpeechEnd: (audio) => {
    // audio is Float32Array at 16kHz
    console.log(`Captured ${audio.length} samples`);
  },
});

vad.start();

API Reference

createVAD(callbacks, config?)

Create a new VAD instance. Requests microphone access, loads the Silero VAD model, and optionally sets up the RNNoise noise suppression pipeline.

import { createVAD } from "@aid-on/vad";

const vad = await createVAD(
  {
    onSpeechStart: () => {
      // User began speaking
      updateUI("listening");
    },
    onSpeechEnd: (audio: Float32Array) => {
      // User stopped speaking
      // audio contains the captured speech at 16kHz mono
      sendToSTT(audio);
    },
    onFrameProcessed: (probability: number) => {
      // Called on each audio frame with speech probability (0-1)
      updateMeter(probability);
    },
    onVADMisfire: () => {
      // Speech was too short (below minSpeechFrames threshold)
      console.log("Too short, ignoring");
    },
  },
  {
    positiveSpeechThreshold: 0.5,
    negativeSpeechThreshold: 0.35,
    minSpeechFrames: 3,
    noiseSuppression: true,
  }
);

Returns: Promise<VADInstance>

VADInstance

The object returned by createVAD().

| Method/Property | Type | Description | |----------------|------|-------------| | start() | () => void | Start listening for speech | | pause() | () => void | Pause listening (retains resources) | | listening | boolean | Whether VAD is currently listening | | destroy() | () => void | Stop listening, release microphone, and clean up all resources |

// Lifecycle
vad.start();              // Begin speech detection
console.log(vad.listening); // true

vad.pause();              // Temporarily stop
console.log(vad.listening); // false

vad.start();              // Resume

vad.destroy();            // Fully clean up (cannot restart after this)

audioToWav(samples, sampleRate?)

Convert a Float32Array of audio samples to a WAV Blob. Useful for sending captured speech to STT APIs.

import { audioToWav } from "@aid-on/vad";

const vad = await createVAD({
  onSpeechEnd: (audio) => {
    // Convert to WAV for uploading to an STT API
    const wavBlob = audioToWav(audio, 16000);

    const formData = new FormData();
    formData.append("file", wavBlob, "speech.wav");

    fetch("/api/transcribe", {
      method: "POST",
      body: formData,
    });
  },
});

Parameters:

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | samples | Float32Array | required | Audio sample data (values between -1 and 1) | | sampleRate | number | 16000 | Sample rate in Hz |

Returns: Blob with MIME type audio/wav

The output is a standard PCM WAV file: mono, 16-bit, with the specified sample rate.

Configuration

VADConfig

| Option | Type | Default | Description | |--------|------|---------|-------------| | positiveSpeechThreshold | number | 0.5 | Probability threshold to detect speech start (0-1) | | negativeSpeechThreshold | number | 0.35 | Probability threshold to detect speech end (0-1) | | minSpeechFrames | number | 3 | Minimum frames to count as speech (prevents misfires) | | preSpeechPadFrames | number | 3 | Number of frames to include before speech start | | redemptionFrames | number | 8 | Frames to wait before considering speech ended | | noiseSuppression | boolean | true | Enable RNNoise-based noise suppression |

VADCallbacks

| Callback | Type | Description | |----------|------|-------------| | onSpeechStart | () => void | Called when speech is detected | | onSpeechEnd | (audio: Float32Array) => void | Called when speech ends, with captured audio data | | onFrameProcessed | (probability: number) => void | Called on each frame with speech probability (0-1) | | onVADMisfire | () => void | Called when detected speech was too short |

Real-World Example: Voice Chat with STT

import { createVAD, audioToWav } from "@aid-on/vad";

// Create VAD with noise suppression for a voice chat application
const vad = await createVAD(
  {
    onSpeechStart: () => {
      statusIndicator.textContent = "Listening...";
      statusIndicator.classList.add("active");
    },
    onSpeechEnd: async (audio) => {
      statusIndicator.textContent = "Processing...";

      // Convert to WAV and send to STT
      const wavBlob = audioToWav(audio, 16000);
      const formData = new FormData();
      formData.append("file", wavBlob, "speech.wav");

      const response = await fetch("/api/transcribe", {
        method: "POST",
        body: formData,
      });

      const { text } = await response.json();
      chatMessages.append(createMessage(text, "user"));

      statusIndicator.textContent = "Ready";
      statusIndicator.classList.remove("active");
    },
    onFrameProcessed: (probability) => {
      // Update a visual speech probability meter
      meterElement.style.width = `${probability * 100}%`;
    },
    onVADMisfire: () => {
      statusIndicator.textContent = "Ready";
    },
  },
  {
    positiveSpeechThreshold: 0.6,   // Slightly higher for noisy environments
    negativeSpeechThreshold: 0.35,
    minSpeechFrames: 5,             // Require longer speech to trigger
    redemptionFrames: 10,           // Wait longer before cutting off
    noiseSuppression: true,         // Enable RNNoise
  }
);

// Start/stop via button
toggleButton.addEventListener("click", () => {
  if (vad.listening) {
    vad.pause();
    toggleButton.textContent = "Start";
  } else {
    vad.start();
    toggleButton.textContent = "Stop";
  }
});

// Cleanup on page unload
window.addEventListener("beforeunload", () => {
  vad.destroy();
});

Architecture

The audio processing pipeline:

Microphone (48kHz)
  |
  +-- [RNNoise] (optional, WebAssembly noise suppression)
  |     480-sample frames at 48kHz
  |
  +-- Silero VAD (ONNX Runtime, speech probability per frame)
  |
  +-- Speech segmentation
        |
        +-- onSpeechStart()
        +-- onSpeechEnd(Float32Array @ 16kHz)
        +-- onVADMisfire()

CDN Dependencies (loaded at runtime):

| Package | Version | Purpose | |---------|---------|---------| | @ricky0123/vad-web | 0.0.18 | Silero VAD model and worklet | | onnxruntime-web | 1.14.0 | ONNX Runtime for WebAssembly inference | | @shiguredo/rnnoise-wasm | ^2025.1.5 | RNNoise noise suppression (bundled) |

License

MIT (C) Aid-On


Real-time voice detection for the browser. Hear what matters.

NPMGitHub