ricky0123 / vad

Voice activity detector (VAD) for the browser with a simple API

Home Page:https://www.vad.ricky0123.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

VAD stopped working. Please advise!

avntsnghchgh opened this issue · comments

I am using this code in the website. It used to work great but i noticed today it has stopped working.
There is an error which is probably related. I am pasting the code and the error below:

<script src="https://cdn.jsdelivr.net/npm/onnxruntime-web/dist/ort.js"></script> <script src="https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@0.0.7/dist/bundle.min.js"></script> <script> async function main() { const myvad = await vad.MicVAD.new({ onSpeechStart: () => { console.log("Speech start detected") }, onSpeechEnd: (audio) => { // do something with `audio` (Float32Array of audio samples at sample rate 16000)... } }) myvad.start() } main() </script>

From Chrome:
wasm-factory.ts:41 env.wasm.numThreads is set to 4, but this will not work unless you enable crossOriginIsolated mode. See https://web.dev/cross-origin-isolation-guide/ for more info.
isMultiThreadSupported @ wasm-factory.ts:41
initializeWebAssembly @ wasm-factory.ts:130
initializeWebAssemblyAndOrtRuntime @ proxy-wrapper.ts:109
init @ backend-wasm.ts:59
tryResolveAndInitializeBackend @ backend-impl.ts:84
resolveBackendAndExecutionProviders @ backend-impl.ts:122
create @ inference-session-impl.ts:199
init @ bundle.min.js:1
async function (async)
init @ bundle.min.js:1
d.new @ bundle.min.js:1
F.init @ bundle.min.js:1
async function (async)
F.init @ bundle.min.js:1
new @ bundle.min.js:1
init @ bundle.min.js:1
async function (async)
init @ bundle.min.js:1
new @ bundle.min.js:1
main @ (index):22
(anonymous) @ (index):39
wasm-core-impl.ts:207 Uncaught (in promise) Error: Can't create a session. failed to allocate a buffer of size 1807522.
at copyFromExternalBuffer (wasm-core-impl.ts:207)
at createSession (wasm-core-impl.ts:235)
at createSession2 (proxy-wrapper.ts:166)
at OnnxruntimeWebAssemblySessionHandler.loadModel (session-handler-inference.ts:67)
at OnnxruntimeWebAssemblyBackend.createInferenceSessionHandler (backend-wasm.ts:71)
at Function.create (inference-session-impl.ts:200)
at async d.init (bundle.min.js:1)
at async Function.d.new (bundle.min.js:1)
at async F.init (bundle.min.js:1)
at async Function.new (bundle.min.js:1)

From Firefox:

[VAD] initializing vad bundle.min.js:1:1917
env.wasm.numThreads is set to 4, but this will not work unless you enable crossOriginIsolated mode. See https://web.dev/cross-origin-isolation-guide/ for more info. wasm-factory.ts:41:14
[VAD] initializing worklet vad.worklet.bundle.min.js:1:239
[VAD] initialized worklet vad.worklet.bundle.min.js:1:239

Uncaught (in promise) Error: Can't create a session. failed to allocate a buffer of size 1807522.
copyFromExternalBuffer wasm-core-impl.ts:207
createSession wasm-core-impl.ts:235
createSession2 proxy-wrapper.ts:166
loadModel session-handler-inference.ts:67
createInferenceSessionHandler backend-wasm.ts:71
create inference-session-impl.ts:200
init bundle.min.js:1
new bundle.min.js:1
init bundle.min.js:1
new bundle.min.js:1
init bundle.min.js:1
new bundle.min.js:1
main (index):22
(index):39
wasm-core-impl.ts:207:10

commented

I've got the same issue. using a packages without version always uses the latest one and sometimes might cause breaking changes. It's a good practice to always use a version.

by adding a version to the onnxruntime-web solves my problem:

<script src="https://cdn.jsdelivr.net/npm/onnxruntime-web@1.18.0/dist/ort.js"></script>

Thanks John (jmgb27), that worked!!

Thanks for bringing this up. I just updated the example in the readme.