Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

With server_vad turn detection, appendInputAudio perf becomes unusable #87

Open
tomlangan opened this issue Dec 14, 2024 · 0 comments
Open

Comments

@tomlangan
Copy link

tomlangan commented Dec 14, 2024

The buffer never stops growing since it's never reset (createResponse() isn't called in server_vad mode). As a result, appendInputAudio's performance degrades drastically as the buffer copy gets bigger and bigger.

This fix seems to work.

appendInputAudio(arrayBuffer) {
if (arrayBuffer.byteLength > 0) {
this.realtime.send('input_audio_buffer.append', {
audio: RealtimeUtils.arrayBufferToBase64(arrayBuffer),
});

/////////// ADD THIS CODE
if (this.sessionConfig.turn_detection?.type !== 'server_vad') {
this.inputAudioBuffer = RealtimeUtils.mergeInt16Arrays(
this.inputAudioBuffer,
arrayBuffer,
);
}
/////////// END ADDED CODE
}
return true;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant