diff --git a/examples/foundational/28a-transcription-processor-openai.py b/examples/foundational/28a-transcription-processor-openai.py index 8b5b943bf..7f1d3dc25 100644 --- a/examples/foundational/28a-transcription-processor-openai.py +++ b/examples/foundational/28a-transcription-processor-openai.py @@ -16,8 +16,7 @@ from runner import configure from pipecat.audio.vad.silero import SileroVADAnalyzer from pipecat.frames.frames import ( - EndFrame, - StartInterruptionFrame, + CancelFrame, TranscriptionMessage, TranscriptionUpdateFrame, ) @@ -170,10 +169,8 @@ async def main(): @transport.event_handler("on_participant_left") async def on_participant_left(transport, participant, reason): - # Interrupt the TTS to stop the TTS generation - await task.queue_frame(StartInterruptionFrame()) - # Stop the gracefully stop the pipeline - await task.queue_frame(EndFrame()) + # Stop the pipeline immediately when the participant leaves + await task.queue_frame(CancelFrame()) runner = PipelineRunner() diff --git a/examples/foundational/28b-transcript-processor-anthropic.py b/examples/foundational/28b-transcript-processor-anthropic.py index 18074e430..b9f95db66 100644 --- a/examples/foundational/28b-transcript-processor-anthropic.py +++ b/examples/foundational/28b-transcript-processor-anthropic.py @@ -16,8 +16,7 @@ from runner import configure from pipecat.audio.vad.silero import SileroVADAnalyzer from pipecat.frames.frames import ( - EndFrame, - StartInterruptionFrame, + CancelFrame, TranscriptionMessage, TranscriptionUpdateFrame, ) @@ -170,10 +169,8 @@ async def main(): @transport.event_handler("on_participant_left") async def on_participant_left(transport, participant, reason): - # Interrupt the TTS to stop the TTS generation - await task.queue_frame(StartInterruptionFrame()) - # Stop the gracefully stop the pipeline - await task.queue_frame(EndFrame()) + # Stop the pipeline immediately when the participant leaves + await task.queue_frame(CancelFrame()) runner = PipelineRunner() diff --git a/examples/foundational/28c-transcription-processor-gemini.py b/examples/foundational/28c-transcription-processor-gemini.py index efa400372..377274ae1 100644 --- a/examples/foundational/28c-transcription-processor-gemini.py +++ b/examples/foundational/28c-transcription-processor-gemini.py @@ -16,8 +16,7 @@ from runner import configure from pipecat.audio.vad.silero import SileroVADAnalyzer from pipecat.frames.frames import ( - EndFrame, - StartInterruptionFrame, + CancelFrame, TranscriptionMessage, TranscriptionUpdateFrame, ) @@ -180,10 +179,8 @@ async def main(): @transport.event_handler("on_participant_left") async def on_participant_left(transport, participant, reason): - # Interrupt the TTS to stop the TTS generation - await task.queue_frame(StartInterruptionFrame()) - # Stop the gracefully stop the pipeline - await task.queue_frame(EndFrame()) + # Stop the pipeline immediately when the participant leaves + await task.queue_frame(CancelFrame()) runner = PipelineRunner() diff --git a/src/pipecat/processors/transcript_processor.py b/src/pipecat/processors/transcript_processor.py index c1a59a166..d31310f84 100644 --- a/src/pipecat/processors/transcript_processor.py +++ b/src/pipecat/processors/transcript_processor.py @@ -10,6 +10,7 @@ from loguru import logger from pipecat.frames.frames import ( BotStoppedSpeakingFrame, + CancelFrame, EndFrame, Frame, StartInterruptionFrame, @@ -115,6 +116,7 @@ class AssistantTranscriptProcessor(BaseTranscriptProcessor): - BotStoppedSpeakingFrame: Completes current utterance - StartInterruptionFrame: Completes current utterance due to interruption - EndFrame: Completes current utterance at pipeline end + - CancelFrame: Completes current utterance due to cancellation Args: frame: Input frame to process @@ -129,7 +131,7 @@ class AssistantTranscriptProcessor(BaseTranscriptProcessor): self._current_text_parts.append(frame.text) - elif isinstance(frame, (BotStoppedSpeakingFrame, StartInterruptionFrame)): + elif isinstance(frame, (BotStoppedSpeakingFrame, StartInterruptionFrame, CancelFrame)): # Emit accumulated text when bot finishes speaking or is interrupted await self._emit_aggregated_text()