From 34762bf604ea7270501ff111c985153285101878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Fri, 17 May 2024 14:15:37 -0700 Subject: [PATCH] transports: allows update allow_interruptinos when receiving StartFrame --- src/pipecat/transports/base_input.py | 6 +++++- src/pipecat/transports/base_output.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/pipecat/transports/base_input.py b/src/pipecat/transports/base_input.py index f3ee492d3..1aa3ceaab 100644 --- a/src/pipecat/transports/base_input.py +++ b/src/pipecat/transports/base_input.py @@ -44,11 +44,15 @@ class BaseInputTransport(FrameProcessor): self._create_push_task() async def start(self, frame: StartFrame): + # Make sure we have the latest params. Note that this transport might + # have been started on another task that might not need interruptions, + # for example. + self._allow_interruptions = frame.allow_interruptions + if self._running: return self._running = True - self._allow_interruptions = frame.allow_interruptions if self._params.audio_in_enabled or self._params.vad_enabled: loop = self.get_event_loop() diff --git a/src/pipecat/transports/base_output.py b/src/pipecat/transports/base_output.py index 7d18f1265..9d6c567b1 100644 --- a/src/pipecat/transports/base_output.py +++ b/src/pipecat/transports/base_output.py @@ -54,11 +54,15 @@ class BaseOutputTransport(FrameProcessor): self._is_interrupted = threading.Event() async def start(self, frame: StartFrame): + # Make sure we have the latest params. Note that this transport might + # have been started on another task that might not need interruptions, + # for example. + self._allow_interruptions = frame.allow_interruptions + if self._running: return self._running = True - self._allow_interruptions = frame.allow_interruptions loop = self.get_event_loop()