From 5341739ecef9e974c87cf867c8dae0d26a9914a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Tue, 17 Dec 2024 16:07:30 -0800 Subject: [PATCH] transport(base output): avoid pushing EndFrame twice --- src/pipecat/transports/base_output.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pipecat/transports/base_output.py b/src/pipecat/transports/base_output.py index fbe337d6d..81471dd37 100644 --- a/src/pipecat/transports/base_output.py +++ b/src/pipecat/transports/base_output.py @@ -242,8 +242,7 @@ async def _sink_frame_handler(self, frame: Frame): await self._set_camera_images(frame.images) elif isinstance(frame, TransportMessageFrame): await self.send_message(frame) - # We will push EndFrame later. - elif not isinstance(frame, EndFrame): + else: await self.push_frame(frame) async def _sink_clock_task_handler(self): @@ -324,6 +323,10 @@ async def _sink_task_handler(self): await self.push_frame(BotSpeakingFrame()) await self.push_frame(BotSpeakingFrame(), FrameDirection.UPSTREAM) + # No need to push EndFrame, it's pushed from process_frame(). + if isinstance(frame, EndFrame): + break + # Handle frame. await self._sink_frame_handler(frame) @@ -333,9 +336,6 @@ async def _sink_task_handler(self): # Send audio. if isinstance(frame, OutputAudioRawFrame): await self.write_raw_audio_frames(frame.audio) - - if isinstance(frame, EndFrame): - break except asyncio.CancelledError: pass except Exception as e: