ricky0123 / vad

Voice activity detector (VAD) for the browser with a simple API
https://www.vad.ricky0123.com
Other
663 stars 105 forks source link

The user aborted a request. #40

Open aditya-pushkar opened 11 months ago

aditya-pushkar commented 11 months ago

I'm getting this error in Nextjs>13.4

next.js.config


/** @type {import('next').NextConfig} */
const CopyPlugin = require("copy-webpack-plugin")
const nextConfig = {
experimental: {
serverActions: true,
},

webpack: (config, {}) => { config.resolve.extensions.push(".ts", ".tsx", '.js', '.jsx') config.resolve.fallback = { fs: false }

config.plugins.push(
  new CopyPlugin({
    patterns: [
      {
        from: "./node_modules/onnxruntime-web/dist/ort-wasm.wasm",
        to: "static/chunks/[name][ext]",
      },
      {
        from: "./node_modules/onnxruntime-web/dist/ort-wasm-simd.wasm",
        to: "static/chunks/[name][ext]",
      },
      {
        from: "node_modules/@ricky0123/vad-web/dist/vad.worklet.bundle.min.js",
        to: "static/chunks/[name][ext]",
      },
      {
        from: "node_modules/@ricky0123/vad-web/dist/*.onnx",
        to: "static/chunks/[name][ext]",
      },
    ],
  })
)
return config

}, }

module.exports = nextConfig


>page.js 

'use client' import { useMicVAD, utils } from "@ricky0123/vad-react" import { useState } from "react"

export const DetectSpeaking = () => { const [audioList, setAudioList] = useState([]) const vad = useMicVAD({ onSpeechEnd: (audio) => { const wavBuffer = utils.encodeWAV(audio) const base64 = utils.arrayBufferToBase64(wavBuffer) const url = data:audio/wav;base64,${base64} setAudioList((old) => { return [url, ...old] }) }, })

if (vad.loading) { return

Loading..........
}

if (vad.errored) { return

{vad.errored.message}
} return (

Listening
{!vad.listening && "Not"} listening
Loading
{!vad.loading && "Not"} loading
Errored
{!vad.errored && "Not"} errored
User Speaking
{!vad.userSpeaking && "Not"} speaking
Audio count
{audioList.length}
Start/Pause

) }

export default DetectSpeaking;

Sequelator123 commented 11 months ago

The same error here in angular 15.2.2 project instantiating MicVAD:

import { MicVAD } from '@ricky0123/vad-web';

this.micVad = await MicVAD.new({ // additionalAudioConstraints: { // deviceId: deviceId // }, //onSpeechStart: this.handleSpeechStart })

Error in browser console: voice-activity-detection.service.ts:75 ERROR Error: Uncaught (in promise): AbortError: The user aborted a request. at resolvePromise (zone.js:1193:31) at zone.js:1100:17 at zone.js:1116:33 at asyncGeneratorStep (asyncToGenerator.js:6:1) at _throw (asyncToGenerator.js:25:1) at _ZoneDelegate.invoke (zone.js:368:26) at Object.onInvoke (core.mjs:24178:33) at _ZoneDelegate.invoke (zone.js:367:52) at Zone.run (zone.js:127:43) at zone.js:1257:36

levity commented 11 months ago

Looks like #24 is related

aditya-pushkar commented 11 months ago

Hey guys, I just used (https://picovoice.ai/platform/cobra/) this module for VAD