I'm getting the same error sending the ulaw_8000 elevenlabs received audio. I'm using javascript but the error is the same. Otherwise, if I use the openai Realtime (in g711_ulaw) response It works fine.
function handleElevenLabsMessage(data, connection, streamSid) {
if (data.audio) {
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const debugDir = path.join(__dirname, 'debug');
if (!fs.existsSync(debugDir)) {
fs.mkdirSync(debugDir);
}
const timestamp = Date.now();
const filename = path.join(debugDir, `ulaw_audio_${timestamp}.ulaw`);
fs.writeFileSync(filename, Buffer.from(data.audio, 'base64'));
console.log(`Saved ulaw audio to ${filename}`);
connection.send(JSON.stringify({
event: 'media',
streamSid: streamSid,
media: {
payload: Buffer.from(data.audio, 'base64').toString('base64')
}
}));
}
}