From 754bedc3ea61119040e7b497dc56ee3821061281 Mon Sep 17 00:00:00 2001 From: Richard Palethorpe Date: Tue, 22 Jul 2025 15:41:12 +0100 Subject: [PATCH] fix(realtime): Reset speech started flag on commit (#5879) Signed-off-by: Richard Palethorpe --- core/http/endpoints/openai/realtime.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/core/http/endpoints/openai/realtime.go b/core/http/endpoints/openai/realtime.go index 1e9fee5fb..b3e756bd8 100644 --- a/core/http/endpoints/openai/realtime.go +++ b/core/http/endpoints/openai/realtime.go @@ -716,6 +716,15 @@ func handleVAD(cfg *config.BackendConfig, evaluator *templates.Evaluator, sessio session.InputAudioBuffer = nil session.AudioBufferLock.Unlock() + sendEvent(c, types.InputAudioBufferSpeechStoppedEvent{ + ServerEventBase: types.ServerEventBase{ + EventID: "event_TODO", + Type: types.ServerEventTypeInputAudioBufferSpeechStopped, + }, + AudioEndMs: time.Now().Sub(startTime).Milliseconds(), + }) + speechStarted = false + sendEvent(c, types.InputAudioBufferCommittedEvent{ ServerEventBase: types.ServerEventBase{ EventID: "event_TODO", @@ -728,14 +737,6 @@ func handleVAD(cfg *config.BackendConfig, evaluator *templates.Evaluator, sessio abytes := sound.Int16toBytesLE(aints) // TODO: Remove prefix silence that is is over TurnDetectionParams.PrefixPaddingMs go commitUtterance(vadContext, abytes, cfg, evaluator, session, conv, c) - - sendEvent(c, types.InputAudioBufferSpeechStoppedEvent{ - ServerEventBase: types.ServerEventBase{ - EventID: "event_TODO", - Type: types.ServerEventTypeInputAudioBufferSpeechStopped, - }, - AudioEndMs: time.Now().Sub(startTime).Milliseconds(), - }) } } }