From e1a7edfb5887b5815e91f6a3353868072c33f73f Mon Sep 17 00:00:00 2001 From: Kwindla Hultman Kramer Date: Fri, 25 Oct 2024 15:59:48 -0500 Subject: [PATCH 1/2] make it possible to use Pipecat turn detection instead of OpenAI turn detection --- src/pipecat/services/openai_realtime_beta/openai.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pipecat/services/openai_realtime_beta/openai.py b/src/pipecat/services/openai_realtime_beta/openai.py index 0c57ed0bb..1df31a17e 100644 --- a/src/pipecat/services/openai_realtime_beta/openai.py +++ b/src/pipecat/services/openai_realtime_beta/openai.py @@ -128,7 +128,7 @@ class OpenAIRealtimeBetaLLMService(LLMService): # async def _handle_interruption(self): - if self._session_properties.turn_detection is None: + if self._session_properties.turn_detection is False: await self.send_client_event(events.InputAudioBufferClearEvent()) await self.send_client_event(events.ResponseCancelEvent()) await self._truncate_current_audio_response() @@ -138,11 +138,10 @@ class OpenAIRealtimeBetaLLMService(LLMService): await self.push_frame(TTSStoppedFrame()) async def _handle_user_started_speaking(self, frame): - if self._session_properties.turn_detection is None: - await self._handle_interruption() + pass async def _handle_user_stopped_speaking(self, frame): - if self._session_properties.turn_detection is None: + if self._session_properties.turn_detection is False: await self.send_client_event(events.InputAudioBufferCommitEvent()) await self.send_client_event(events.ResponseCreateEvent()) From 93c6e5098ce51be4b167396b9750f478844f3892 Mon Sep 17 00:00:00 2001 From: Kwindla Hultman Kramer Date: Sat, 2 Nov 2024 08:24:54 -0700 Subject: [PATCH 2/2] added comment explaining config of TurnDetection --- src/pipecat/services/openai_realtime_beta/openai.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pipecat/services/openai_realtime_beta/openai.py b/src/pipecat/services/openai_realtime_beta/openai.py index 1df31a17e..fcac357fa 100644 --- a/src/pipecat/services/openai_realtime_beta/openai.py +++ b/src/pipecat/services/openai_realtime_beta/openai.py @@ -128,6 +128,8 @@ class OpenAIRealtimeBetaLLMService(LLMService): # async def _handle_interruption(self): + # None and False are different. Check for False. None means we're using OpenAI's + # built-in turn detection defaults. if self._session_properties.turn_detection is False: await self.send_client_event(events.InputAudioBufferClearEvent()) await self.send_client_event(events.ResponseCancelEvent()) @@ -141,6 +143,8 @@ class OpenAIRealtimeBetaLLMService(LLMService): pass async def _handle_user_stopped_speaking(self, frame): + # None and False are different. Check for False. None means we're using OpenAI's + # built-in turn detection defaults. if self._session_properties.turn_detection is False: await self.send_client_event(events.InputAudioBufferCommitEvent()) await self.send_client_event(events.ResponseCreateEvent())