diff --git a/src/pipecat/services/ai_services.py b/src/pipecat/services/ai_services.py index 197067adc..21ef8dfca 100644 --- a/src/pipecat/services/ai_services.py +++ b/src/pipecat/services/ai_services.py @@ -259,6 +259,10 @@ def __init__( async def flush_audio(self): pass + async def say(self, text: str): + await super.say(text) + await self.flush_audio() + async def start(self, frame: StartFrame): await super().start(frame) if self._push_stop_frames: @@ -278,6 +282,11 @@ async def cancel(self, frame: CancelFrame): await self._stop_frame_task self._stop_frame_task = None + async def process_frame(self, frame: Frame, direction: FrameDirection): + await super().process_frame(frame, direction) + if isinstance(frame, TTSSpeakFrame): + await self.flush_audio() + async def push_frame(self, frame: Frame, direction: FrameDirection = FrameDirection.DOWNSTREAM): await super().push_frame(frame, direction)