diff --git a/CHANGELOG.md b/CHANGELOG.md index a643b7a3e..14b779f47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Added `skip_tts` field to `TextFrame`. This lets a text frame bypass TTS while + still being included in the LLM context. Useful for cases like structured text + that isn’t meant to be spoken but should still contribute to context. + - Added a `cancel_timeout_secs` argument to `PipelineTask` which defines how long the pipeline has to complete cancellation. When `PipelineTask.cancel()` is called, a `CancelFrame` is pushed through the pipeline and must reach the diff --git a/src/pipecat/frames/frames.py b/src/pipecat/frames/frames.py index 139857297..18ab13bac 100644 --- a/src/pipecat/frames/frames.py +++ b/src/pipecat/frames/frames.py @@ -305,6 +305,11 @@ class TextFrame(DataFrame): """ text: str + skip_tts: bool = field(init=False) + + def __post_init__(self): + super().__post_init__() + self.skip_tts = False def __str__(self): pts = format_pts(self.pts) diff --git a/src/pipecat/services/tts_service.py b/src/pipecat/services/tts_service.py index 2a210f093..afe5da62d 100644 --- a/src/pipecat/services/tts_service.py +++ b/src/pipecat/services/tts_service.py @@ -296,7 +296,9 @@ class TTSService(AIService): """ await super().process_frame(frame, direction) - if ( + if isinstance(frame, TextFrame) and frame.skip_tts: + await self.push_frame(frame, direction) + elif ( isinstance(frame, TextFrame) and not isinstance(frame, InterimTranscriptionFrame) and not isinstance(frame, TranscriptionFrame)