-
Notifications
You must be signed in to change notification settings - Fork 47
Open
Description
Hello Dear,
I've an issue while integrate Asterisk with OpenAi using Realtime API. Shortly, I use Audiosocke to connect with Asterisk and then once the connection has begun, I start the OpenAi connection. When I use res.play function out of OpenAi connection function it works fine, but when I use it inside OpenAi connection the played file is lagging and you cannot recognize the voice.
`
audioSocket.onConnection(async (req, res) => {
openAiWs.on( 'message', async (data) => {
await res.play("/root/moh.wav");
try {
const response = JSON.parse(data);
if (response.type === 'response.audio.delta' && response.delta) {
/*const audioDelta = {
event: 'media',
streamSid: streamSid,
media: { payload: response.delta }
};*/
//console.log(typeof data); // Should output 'object' for Buffer
//console.log(Buffer.isBuffer(data)); // Should output true if data is a Buffer
//console.log('Firstone:', response);
const finaldata = Buffer.from(response.delta, "base64");
//console.log('Final Data is:', finaldata);
//await res.write(finaldata);
await res.play("/root/moh.wav");
}
} catch (error) {
console.error('Error processing OpenAI message:', error, 'Raw message:', data);
}
});
});
`
Metadata
Metadata
Assignees
Labels
No labels