OpenGlass
OpenGlass copied to clipboard
browser console error
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.
ahh i have run into the same error
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""?
I confirm that I have chosen OPI PSRAM.
await audioContext.decodeAudioData
在这之前增加哥判断如果audioContext没有初始化,则初始化它 if (!audioContext) { await startAudio(); }