BasedHardware / OpenGlass

Turn any glasses into AI-powered smart glasses
https://openglass.ai
MIT License
2.78k stars 339 forks source link

browser console error #20

Open mcy567 opened 1 month ago

mcy567 commented 1 month ago

053c59f55af9b7a527c1492a231ebd3 Error message:

Error in textToSpeech: TypeError: Cannot read properties of undefined (reading 'decodeAudioData')

Related Codes


    try {
      console.log("aaaaaaaaaaaaaa:", text);
      const response = await _axios.default.post("https://uiuiapi.com/v1/audio/speech", {
        input: text,
        // Use 'input' instead of 'text'
        voice: "nova",
        model: "tts-1"
      }, {
        headers: {
          'Authorization': `Bearer ${_keys.keys.openai}`,
          // Replace YOUR_API_KEY with your actual OpenAI API key
          'Content-Type': 'application/json'
        },
        responseType: 'arraybuffer' // This will handle the binary data correctly
      });
      console.log("bbbbbbbb", response);
      console.log("bbbbbbbb", response.data);

      // Decode the audio data asynchronously
      const audioBuffer = await audioContext.decodeAudioData(response.data);

      // Create an audio source
      const source = audioContext.createBufferSource();
      source.buffer = audioBuffer;
      source.connect(audioContext.destination);
      source.start(); // Play the audio immediately

      return response.data;
    } catch (error) {
      console.error("Error in textToSpeech:", error);
      return null; // or handle error differently
    }
  }```
I don't know where the problem is.I hope I can get some help.
Yuanzan commented 1 month ago

ahh i have run into the same error

silentlit commented 1 month ago

Did you follow the readme :"Before you flash go to the "Tools" drop down in the Arduino IDE and make sure you set "PSRAM:" to be "PSRAM: "OPI PSRAM""?

mcy567 commented 1 month ago

I confirm that I have chosen OPI PSRAM. 微信图片_20240530201550