@ericedouard/vad-node-realtime

中文文档
0.2.0发布于 2025/04/17ISCTypeScriptCommonJS近 30 天下载 4447

Powerful, user-friendly realtime voice activity detector (VAD) for node

原始使用文档
文档目录9 节
  1. Features
  2. Installation
  3. Usage
  4. Real-time VAD
  5. Non-real-time VAD
  6. API Reference
  7. RealTimeVAD
  8. RealTimeVADOptions
  9. License

Forked from https://github.com/ricky0123/vad which supports web and react. It used to support node, but it wasn't realtime. Here it's based for node and realtime.

See the project home for more details.

Features

  • Real-time and non-real-time voice activity detection
  • Built on the Silero VAD model
  • Easy to use API
  • Works completely offline
  • Efficient processing for server environments

Installation

npm install @ericedouard/vad-node-realtime

Usage

Real-time VAD

Use RealTimeVAD when you need to process audio chunks in real time, such as receiving audio from a client application:

const { RealTimeVAD } = require('@eric-edouard/vad-node-realtime');

async function example() {
  // Create a new RealTimeVAD instance
  const vad = await RealTimeVAD.new({
    onSpeechStart: () => {
      console.log('Speech started');
    },
    onSpeechEnd: (audio) => {
      console.log('Speech ended, received audio of length:', audio.length);
      // Process the audio data here
    },
    // Optional: customize VAD parameters
    positiveSpeechThreshold: 0.6,
    negativeSpeechThreshold: 0.4,
    minSpeechFrames: 4,
  });

  // Start processing
  vad.start();

  // When you receive audio chunks from your source:
  function onAudioChunkReceived(audioChunk) {
    // Process each chunk of audio data
    // audioChunk should be a Float32Array with sample rate matching the sampleRate option (default: 16000Hz)
    await vad.processAudio(audioChunk);
  }

  // When you're done with the stream:
  await vad.flush(); // Process any remaining audio
  vad.destroy(); // Clean up resources
}

example();

Non-real-time VAD

For processing entire audio files or pre-recorded chunks:

const { NonRealTimeVAD } = require('@eric-edouard/vad-node-realtime');

async function example() {
  const vad = await NonRealTimeVAD.new();
  
  // audioData is a Float32Array of audio samples
  // sampleRate is the sample rate of the audio
  for await (const { audio, start, end } of vad.run(audioData, sampleRate)) {
    console.log(`Speech detected from ${start}ms to ${end}ms`);
    // Process detected speech segment
  }
}

API Reference

RealTimeVAD

  • RealTimeVAD.new(options): Create a new RealTimeVAD instance
  • start(): Start processing audio
  • pause(): Pause processing audio
  • processAudio(audioData): Process a chunk of audio data
  • flush(): Process any remaining audio and trigger final callbacks
  • reset(): Reset the VAD state
  • destroy(): Clean up resources

RealTimeVADOptions

  • sampleRate: Sample rate of the input audio (default: 16000, inputs with different sample rates will be automatically resampled)
  • onSpeechStart: Callback when speech starts
  • onSpeechEnd: Callback when speech ends, with the audio data
  • onVADMisfire: Callback when speech was detected but was too short
  • onFrameProcessed: Callback after each frame is processed
  • positiveSpeechThreshold: Threshold for detecting speech (0-1)
  • negativeSpeechThreshold: Threshold for detecting silence (0-1)
  • minSpeechFrames: Minimum number of frames to consider as speech

License

ISC

版本与发布记录

@ericedouard/vad-node-realtime 共发布 6 个版本,首次发布于 2025/04/14;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.2.0latest2025/04/171.6 年前
0.1.22025/04/141.6 年前
0.1.12025/04/141.6 年前
0.1.02025/04/141.6 年前
0.0.22025/04/141.6 年前
0.0.12025/04/141.6 年前

关于 @ericedouard/vad-node-realtime 的常见问题

@ericedouard/vad-node-realtime 是什么?

Powerful, user-friendly realtime voice activity detector (VAD) for node

如何安装 @ericedouard/vad-node-realtime?

在项目目录运行 npm install @ericedouard/vad-node-realtime,或使用 pnpm add / yarn add / bun add。

@ericedouard/vad-node-realtime 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@ericedouard/vad-node-realtime 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@ericedouard/vad-node-realtime 可以商用吗?

@ericedouard/vad-node-realtime 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@ericedouard/vad-node-realtime 的下载量有多少?

根据 npm 官方下载统计,@ericedouard/vad-node-realtime 在 2026/10/14 – 2026/11/12 这 30 天内被下载 4,447 次,日均约 148 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@ericedouard/vad-node-realtime 还在维护吗?

最新版本 0.2.0 发布于 2025/04/17(1.6 年前);至今共发布 6 个版本,其中过去 12 个月发布了 0 个;首次发布于 2025/04/14。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。