From 5426891feb67a318fbc0601e4e95dde5edfe2bb1 Mon Sep 17 00:00:00 2001 From: Kwindla Hultman Kramer Date: Mon, 7 Oct 2024 15:46:33 -0700 Subject: [PATCH] added input audio pause setting. no frame to update that state, yet. --- .../openai_realtime_beta/llm_and_context.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/pipecat/services/openai_realtime_beta/llm_and_context.py b/src/pipecat/services/openai_realtime_beta/llm_and_context.py index 83e09e0fa..71775883f 100644 --- a/src/pipecat/services/openai_realtime_beta/llm_and_context.py +++ b/src/pipecat/services/openai_realtime_beta/llm_and_context.py @@ -117,22 +117,26 @@ class OpenAILLMServiceRealtimeBeta(LLMService): api_key: str, base_url="wss://api.openai.com/v1/realtime?model=gpt-4o-realtime-preview-2024-10-01", session_properties: events.SessionProperties = events.SessionProperties(), + start_audio_paused: bool = False, **kwargs, ): super().__init__(base_url=base_url, **kwargs) self.api_key = api_key self.base_url = base_url - self._websocket = None - self._receive_task = None self._session_properties = session_properties + self._audio_input_paused = start_audio_paused + self._websocket = None + self._receive_task = None self._context = None - self._bot_speaking = False def can_generate_metrics(self) -> bool: return True + def set_audio_input_paused(self, paused: bool): + self._audio_input_paused = paused + async def start(self, frame: StartFrame): await super().start(frame) await self._connect() @@ -386,7 +390,8 @@ class OpenAILLMServiceRealtimeBeta(LLMService): self._context = context await self._create_response() elif isinstance(frame, InputAudioRawFrame): - await self._send_user_audio(frame) + if not self._audio_input_paused: + await self._send_user_audio(frame) elif isinstance(frame, StartInterruptionFrame): await self._handle_interruption(frame) elif isinstance(frame, _InternalMessagesUpdateFrame):