Skip to content

Commit 754bedc

Browse files
authored
fix(realtime): Reset speech started flag on commit (#5879)
Signed-off-by: Richard Palethorpe <[email protected]>
1 parent 98e5291 commit 754bedc

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

core/http/endpoints/openai/realtime.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,15 @@ func handleVAD(cfg *config.BackendConfig, evaluator *templates.Evaluator, sessio
716716
session.InputAudioBuffer = nil
717717
session.AudioBufferLock.Unlock()
718718

719+
sendEvent(c, types.InputAudioBufferSpeechStoppedEvent{
720+
ServerEventBase: types.ServerEventBase{
721+
EventID: "event_TODO",
722+
Type: types.ServerEventTypeInputAudioBufferSpeechStopped,
723+
},
724+
AudioEndMs: time.Now().Sub(startTime).Milliseconds(),
725+
})
726+
speechStarted = false
727+
719728
sendEvent(c, types.InputAudioBufferCommittedEvent{
720729
ServerEventBase: types.ServerEventBase{
721730
EventID: "event_TODO",
@@ -728,14 +737,6 @@ func handleVAD(cfg *config.BackendConfig, evaluator *templates.Evaluator, sessio
728737
abytes := sound.Int16toBytesLE(aints)
729738
// TODO: Remove prefix silence that is is over TurnDetectionParams.PrefixPaddingMs
730739
go commitUtterance(vadContext, abytes, cfg, evaluator, session, conv, c)
731-
732-
sendEvent(c, types.InputAudioBufferSpeechStoppedEvent{
733-
ServerEventBase: types.ServerEventBase{
734-
EventID: "event_TODO",
735-
Type: types.ServerEventTypeInputAudioBufferSpeechStopped,
736-
},
737-
AudioEndMs: time.Now().Sub(startTime).Milliseconds(),
738-
})
739740
}
740741
}
741742
}

0 commit comments

Comments
 (0)