Skip to content

Commit

Permalink
transport(base output): avoid pushing EndFrame twice
Browse files Browse the repository at this point in the history
  • Loading branch information
aconchillo committed Dec 19, 2024
1 parent fb9f72d commit 5341739
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/pipecat/transports/base_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)

Expand All @@ -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:
Expand Down

0 comments on commit 5341739

Please sign in to comment.