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

@jjhbw/silero-vad

v1.0.3

Published

Node.js bindings for Silero VAD

Downloads

448

Readme

Silero VAD Node

Minimal Node.js wrapper around the Silero VAD ONNX model, with a small CLI and parity tests against the Python implementation. The Node implementation runs VAD and silence stripping directly from ffmpeg streams to keep memory usage low on long files.

Install

npm install @jjhbw/silero-vad

Requires Node 18+ and ffmpeg available on PATH for decoding arbitrary audio formats.

Library usage

const {
  loadSileroVad,
  getSpeechTimestamps,
  writeStrippedAudio,
  WEIGHTS,
} = require("@jjhbw/silero-vad");

(async () => {
  const vad = await loadSileroVad("default"); // or WEIGHTS keys/custom path
  try {
    if (!vad.sampleRate) throw new Error("Model sample rate is undefined");
    const inputs = ["input.wav", "other.mp3"];
    for (const inputPath of inputs) {
      vad.resetStates(); // per file/stream
      const ts = await getSpeechTimestamps(inputPath, vad);
      // Each entry includes both seconds (start/end) and samples (startSample/endSample).
      console.log(inputPath, ts);
      // Example return value:
      // [
      //   { start: 0.36, end: 1.92, startSample: 5760, endSample: 30720 },
      //   { start: 2.41, end: 3.05, startSample: 38560, endSample: 48800 }
      // ]

      // Strip silences from the original file using the timestamps.
      // Pick any extension supported by ffmpeg (e.g., .wav, .flac).
      // Note: encoding speed varies by container/codec; uncompressed PCM (e.g., .wav) is fastest,
      // lossless compression (e.g., .flac) is slower, and lossy codecs (e.g., .mp3/.aac/.opus)
      // are typically the slowest to encode.
      const outPath = inputPath.replace(/\.[^.]+$/, ".stripped.wav");
      await writeStrippedAudio(inputPath, ts, vad.sampleRate, outPath);
    }
  } finally {
    await vad.session.release?.(); // once per process when shutting down
  }
})();

Guidelines:

  • Load once, reuse: keep one SileroVad per concurrent worker.
  • Call resetStates() before each new file/stream; the session and weights stay in memory.
  • Call release() when shutting down.

CLI

npx @jjhbw/silero-vad --audio input.wav --audio other.mp3 [options]

Options:

  • --model <key|path>: model key (default, 16k, 8k_16k, half, op18) or custom ONNX path (default: default, i.e., bundled 16k op15).
  • --threshold <float>: speech probability threshold (default 0.5).
  • --min-speech-ms <ms>: minimum speech duration in ms (default 250).
  • --min-silence-ms <ms>: minimum silence duration in ms (default 100).
  • --speech-pad-ms <ms>: padding added to each speech segment in ms (default 30).
  • --time-resolution <n>: decimal places for seconds output (default 3).
  • --neg-threshold <float>: override the negative threshold (default max(threshold - 0.15, 0.01)).
  • --cps <float>: enable the timeline visualization and set chars per second (default 4).
  • --strip-silence: write a new WAV file with silences removed.
  • --output-dir <path>: output directory for strip-silence files (default: input dir).

Outputs an array of { file, timestamps } to stdout as JSON. The CLI reuses a single ONNX session and resets state per file. The sample rate is defined by the selected model (read from vad.sampleRate).

Development

Clone the repo to run benchmarks and tests locally.

Benchmark

git clone https://github.com/jjhbw/silero-vad
cd silero-vad/js-fork
npm install
node bench.js --audio data/test.mp3 --runs 5

The benchmark reports timings per file for streaming VAD and silence stripping. Stripped-audio files are written to a temporary directory and removed after each run.

Tests

Snapshot tests compare Node outputs against Python ground truth (tests/snapshots/onnx.json):

git clone https://github.com/jjhbw/silero-vad
cd silero-vad/js-fork
npm install
npm test

Ensure Python snapshots are generated (run pytest tests/test_snapshots.py in the repo root) and ffmpeg is installed.