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

RuntimeError: memory access out of bounds - React

praful45 opened this issue · comments

I encountered a RuntimeError: memory access out of bounds when trying to load a model . The error appears to be related to the ort-wasm-simd.wasm file. Below is the detailed error log:

RuntimeError: memory access out of bounds
at ort-wasm-simd.wasm:0x15540
at Qp (main.a2cdd5c3.js:2:1378025)
at ld (main.a2cdd5c3.js:2:1442354)
at Co.loadModel (main.a2cdd5c3.js:2:1443997)
at Fo.createInferenceSessionHandler (main.a2cdd5c3.js:2:1445544)
at e.create (main.a2cdd5c3.js:2:912118)
at async a.init (main.a2cdd5c3.js:2:4757)
at async a.new (main.a2cdd5c3.js:2:5340)
at async d.new (main.a2cdd5c3.js:2:14105)
at async u.new (main.a2cdd5c3.js:2:13208)

it is implemented in this way

import * as vad from '@ricky0123/vad-web';
......
......
  public async initialize() {
    try {
      this.vadInstance = await vad.MicVAD.new({
        modelURL:
          'https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@0.0.18/dist/silero_vad.onnx',
        workletURL:
          'https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@0.0.18/dist/vad.worklet.bundle.min.js',
        positiveSpeechThreshold: 0.8,
        minSpeechFrames: 5,
        preSpeechPadFrames: 10,
        onSpeechEnd: (arr: Float32Array) => {
          this.speechLength += arr.length / this.audioSampleRate;
          return this.speechLength;
        },
      });
    } catch (e: any) {
      if (e.name === 'AbortError') {
        throw new Error(`VAD initialization aborted by the user: ${e.message}`);
      } else {
        console.log(e);
        throw new Error(`Failed to initialize VAD: ${e.message}`);
      }
    }
  }