Discussions
Whisper API Error When Filtering Low-Volume Audio in Next.js with Vite & Heygen SST
about 1 month ago by Ahmad
Hello,
I used Heygen SST code with VITE in my NextJS code, the reason? I want to do my own mic senstivity feature, the thing is I tried to implment my own fucntion that analyze the user volume level and depending on that it takes the audiochunk or not
this.mediaRecorder.ondataavailable = (event) => {
if (event.data.size > 0 && this.micAnalyzer?.isAboveVolumeThreshold()) {
console.log('Received audio chunk:', event.data.size, 'bytes');
this.audioChunks.push(event.data);
}
};
but the thing is I kept getting errors from whisper openAI says
Failed to load resource: the server responded with a status of 400 ()
button.tsx:2 Error transcribing audio: Error: HTTP error! status: 400, details: {
"error": {
"message": "Invalid file format. Supported formats: ['flac', 'm4a', 'mp3', 'mp4', 'mpeg', 'mpga', 'oga', 'ogg', 'wav', 'webm']",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
at AudioRecorder.sendToWhisper (src_3f3f87._.js:305:23)
at async mediaRecorder.onstop (audio-handler.ts:47:17)
sendToWhisper @ button.tsx:2
My goal is to not make a transcript whenever the user volume is low, why? because sometimes when we show the interactive avatar we have an audince next to us and they start talking with each other about the avatar but this interrput the avatar so we dont want to do this.
Kindly find the SST vite code which is the same as my code here