Abort realtime turn on speech start

This commit is contained in:
Mohamed Boudra
2025-11-15 18:21:02 +01:00
parent e7b8cc373c
commit 673c6f1594
2 changed files with 15 additions and 1 deletions
@@ -41,6 +41,19 @@ export function RealtimeProvider({ children }: RealtimeProviderProps) {
if (isPlayingAudio) {
audioPlayer.stop();
}
// Abort any in-flight LLM turn before the new speech segment streams
try {
const abortMessage: WSInboundMessage = {
type: "session",
message: {
type: "abort_request",
},
};
ws.send(abortMessage);
console.log("[Realtime] Sent abort_request before streaming audio");
} catch (error) {
console.error("[Realtime] Failed to send abort_request:", error);
}
},
onSpeechEnd: () => {
console.log("[Realtime] Speech ended");