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, + } + } }