From 0d85c0085f34a737c8f62a1d8349f27efd930eb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Sun, 11 Aug 2024 23:06:39 -0700 Subject: [PATCH] processors(rtvi): interrupt the bot if a new config is received --- src/pipecat/processors/frameworks/rtvi.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/pipecat/processors/frameworks/rtvi.py b/src/pipecat/processors/frameworks/rtvi.py index 137d97299..abedd0c89 100644 --- a/src/pipecat/processors/frameworks/rtvi.py +++ b/src/pipecat/processors/frameworks/rtvi.py @@ -15,6 +15,8 @@ from pipecat.frames.frames import ( Frame, InterimTranscriptionFrame, StartFrame, + StartInterruptionFrame, + StopInterruptionFrame, SystemFrame, TranscriptionFrame, TransportMessageFrame, @@ -382,6 +384,12 @@ class RTVIProcessor(FrameProcessor): await self._update_service_config(service_config) async def _handle_update_config(self, request_id: str, data: RTVIConfig): + # NOTE(aleix): The bot might be talking while we receive a new + # config. Let's interrupt it for now and update the config. Another + # solution is to wait until the bot stops speaking and then apply the + # config, but this definitely is more complicated to achieve. + await self.push_frame(StartInterruptionFrame()) + await self.push_frame(StopInterruptionFrame()) await self._update_config(data) await self._handle_get_config(request_id)