Merge pull request #666 from pipecat-ai/khk/realtime-pipecat-vad

Support using Pipecat turn detection instead of OpenAI Realtime API turn detection
This commit is contained in:
Kwindla Hultman Kramer
2024-11-02 08:36:31 -07:00
committed by GitHub

View File

@@ -128,7 +128,9 @@ class OpenAIRealtimeBetaLLMService(LLMService):
#
async def _handle_interruption(self):
if self._session_properties.turn_detection is None:
# 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())
await self._truncate_current_audio_response()
@@ -138,11 +140,12 @@ 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:
# 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())