ame

@xz-academy/vad-vue (0.2.0)

Published 2025-10-21 17:51:09 +08:00 by ame

Installation

@xz-academy:registry=
npm install @xz-academy/vad-vue@0.2.0
"@xz-academy/vad-vue": "0.2.0"

About this package

vad-vue

基于 @ricky0123/vad-web 、参考 @ricky0123/vad-react 实现的 VAD Vue Composable。增加了一点微小的功能。

构建

pnpm -F vad-vue build

API

import { useMicVAD, getDefaultVueRealTimeVADOptions, utils } from "vad-vue"
  • useMicVAD(options) 返回:
    • listening - ref<boolean>
    • errored - ref<false | string>
    • loading - ref<boolean>
    • userSpeaking - ref<boolean>
    • pause() / start() / toggle()

options@ricky0123/vad-webRealTimeVADOptions 一致,此外本包还有:

  • startOnLoad(默认 true)
  • userSpeakingThreshold(默认 0.6)
  • speechChunkMs(默认 500)
  • onSpeechChunkCollected - (frames: Float32Array[]) => void,音频 buffer 提交事件。

支持 @ricky0123/vad-web 的所有回调(onSpeechStartonSpeechRealStartonVADMisfireonSpeechEndonFrameProcessed)。

注意

  • 默认使用 @ricky0123/vad-web 的默认 CDN 设置。
  • 需要麦克风权限;必须在安全上下文中使用。

与 vad-react 的区别

  • uttering - ref<boolean>,表示当前是否正在说话。不受 userSpeakingThreshold 的影响,只有真正说话(positive frame 达到 minSpeechMs)才会改变。
  • speechChunkMs - speechChunkMs,说话时收集音频数据并存储到 buffer,每隔 speechChunkMs 将 buffer 中数据提交到 onSpeechChunkCollected
  • onSpeechChunkCollected - (frames: Float32Array[]) => void,音频 buffer 提交事件。会包含正式说话(userOnSpeechRealStart 触发)前 preSpeechMs 的音频数据。

Dependencies

Dependencies

ID Version
@ricky0123/vad-web ^0.0.27
onnxruntime-web ^1.17.0

Development Dependencies

ID Version
tsdown ^0.13.3
typescript ^5.5.4

Peer Dependencies

ID Version
@vueuse/core >=10.0.0
vue >=3.2.0
Details
npm
2025-10-21 17:51:09 +08:00
5
ISC
latest
5.8 KiB
Assets (1)
Versions (1) View all
0.2.0 2025-10-21