Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encountered an error while loading model file #169

Open
RizanKhan837 opened this issue Dec 7, 2024 · 2 comments
Open

Encountered an error while loading model file #169

RizanKhan837 opened this issue Dec 7, 2024 · 2 comments

Comments

@RizanKhan837
Copy link

keep geeting this error while i run my code
real-time-vad.ts:238 Encountered an error while loading model file https://cdn.jsdelivr.net/npm/@ricky0123/[email protected]/dist/silero_vad_v5.onnx

here's how i used it.

  const vad = useMicVAD({
    model: "v5",
    startOnLoad: true,
    onSpeechEnd: async (audio) => {
      // Prevent multiple simultaneous processing
      if (isProcessing) return;

      setIsProcessing(true);

      try {
        // Convert audio to base64 for storage or transmission if needed
        const wavBuffer = utils.encodeWAV(audio);
        const base64 = utils.arrayBufferToBase64(wavBuffer);
        const audioUrl = `data:audio/wav;base64,${base64}`;

        // Add audio to list for playback
        setAudioList((old) => [audioUrl, ...old]);

        // Convert audio blob for transcription
        const audioBlob = new Blob([wavBuffer], { type: "audio/wav" });

        // Transcribe audio
        const transcription = await STTService.transcribeAudio(audioBlob);

        if (transcription) {
          // Process transcription with local AI model
          const response = await processWithLocalAI(transcription);

          // Synthesize speech response
          if (response) {
            await TTSService.synthesizeSpeech(response);
          }
        }
      } catch (error) {
        console.error("Voice assistant error:", error);
      } finally {
        setIsProcessing(false);
      }
    },
  });

here is my webpack config

const CopyPlugin = require("copy-webpack-plugin");

module.exports = {
entry: "./src/index.jsx",
module: {
  rules: [
    {
      test: /\.m?jsx?$/,
      exclude: /node_modules/,
      use: {
        loader: "babel-loader",
        options: {
          presets: [["@babel/preset-react"]],
        },
      },
    },
  ],
},
plugins: [
  new CopyPlugin({
    patterns: [
      {
        from: "node_modules/@ricky0123/vad-web/dist/vad.worklet.bundle.min.js",
        to: "src/components/VoiceAssistant.js",
      },
      {
        from: "node_modules/@ricky0123/vad-web/dist/*.onnx",
        to: "src/components/VoiceAssistant.js",
      },
      {
        from: "node_modules/onnxruntime-web/dist/*.wasm",
        to: "src/components/VoiceAssistant.js",
      },
      { from: "src/index.html", to: "[name][ext]" },
    ],
  }),
],
output: {
  clean: true,
},
};

@zhenxy0503
Copy link

me too

@ricky0123
Copy link
Owner

Hi, can you look in the network tab of browser dev tools and see where it is trying to load the vad from? Is it getting a 404?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants