Skip to content

Commit

Permalink
Merge pull request #883 from pipecat-ai/aleix/base-output-transport-a…
Browse files Browse the repository at this point in the history
…void-pushing-endframe

transport(base output): avoid pushing EndFrame twice
  • Loading branch information
aconchillo authored Dec 19, 2024
2 parents 5b0fc3f + 5341739 commit e08c24d
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 e08c24d

Please sign in to comment.