From 1d6d8b29902b7288fb985c5a3e3601c69135cf75 Mon Sep 17 00:00:00 2001 From: tisDDM <77615100+tisDDM@users.noreply.github.com> Date: Tue, 7 Jan 2025 02:20:48 +0100 Subject: [PATCH] Fork for dynamically adjust vad parameters #173 (#178) * changes to adjust VAD parameters dynamically in web package * changes to adjust VAD parameters dynamically in web package * changes to adjust VAD parameters dynamically in web package --------- Co-authored-by: Tim Co-authored-by: Ricky Samore --- changelogs/web-changelog.md | 1 + packages/web/src/real-time-vad.ts | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/changelogs/web-changelog.md b/changelogs/web-changelog.md index 679e03c..224d274 100644 --- a/changelogs/web-changelog.md +++ b/changelogs/web-changelog.md @@ -2,6 +2,7 @@ ## 0.0.23 +* add support to change VAD parameters dynamically [#137] https://github.com/ricky0123/vad/issues/173 * add onRealSpeechStart callback - "not a misfire" event (https://github.com/ricky0123/vad/issues/67) ## 0.0.22 diff --git a/packages/web/src/real-time-vad.ts b/packages/web/src/real-time-vad.ts index 3df5c6a..20d6355 100644 --- a/packages/web/src/real-time-vad.ts +++ b/packages/web/src/real-time-vad.ts @@ -196,6 +196,10 @@ export class MicVAD { this.audioNodeVAD.destroy() this.audioContext.close() } + + setOptions = (options) => { + this.audioNodeVAD.setFrameProcessorOptions(options) + } } export class AudioNodeVAD { @@ -409,4 +413,11 @@ export class AudioNodeVAD { this.audioNode.disconnect() this.gainNode?.disconnect() } + + setFrameProcessorOptions = (options) => { + this.frameProcessor.options = { + ...this.frameProcessor.options, + ...options, + } + } }