From e1528d0f0c737a43d68099d0f29cea5a9a9328f5 Mon Sep 17 00:00:00 2001 From: mattie ruth backman Date: Mon, 17 Nov 2025 16:59:27 -0500 Subject: [PATCH] Added support to TTS services to skip sending text to the... the actual TTS service to be spoken based on its aggregation type. --- CHANGELOG.md | 4 ++++ src/pipecat/services/tts_service.py | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95cc4d564..89f6d38e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -159,6 +159,10 @@ Croatian, Hungarian, Malay, Norwegian, Nynorsk, Slovak, Slovenian, Swedish, and encompassing text should be added to the LLM context (by the LLM assistant aggregator). It defaults to `True`. + - `TTSService` base class updates: + - `TTSService`s now accept a new `skip_aggregator_types` to avoid speaking certain aggregation + types (now determined/returned by the aggregator) + ### Deprecated - The `api_key` parameter in `GeminiTTSService` is deprecated. Use diff --git a/src/pipecat/services/tts_service.py b/src/pipecat/services/tts_service.py index 2267ee29f..637077f10 100644 --- a/src/pipecat/services/tts_service.py +++ b/src/pipecat/services/tts_service.py @@ -103,6 +103,8 @@ class TTSService(AIService): sample_rate: Optional[int] = None, # Text aggregator to aggregate incoming tokens and decide when to push to the TTS. text_aggregator: Optional[BaseTextAggregator] = None, + # Types of text aggregations that should not be spoken. + skip_aggregator_types: Optional[List[str]] = [], # Text filter executed after text has been aggregated. text_filters: Optional[Sequence[BaseTextFilter]] = None, text_filter: Optional[BaseTextFilter] = None, @@ -121,6 +123,7 @@ class TTSService(AIService): silence_time_s: Duration of silence to push when push_silence_after_stop is True. pause_frame_processing: Whether to pause frame processing during audio generation. sample_rate: Output sample rate for generated audio. + skip_aggregator_types: List of aggregation types that should not be spoken. text_aggregator: Custom text aggregator for processing incoming text. .. deprecated:: 0.0.95 @@ -158,6 +161,7 @@ class TTSService(AIService): DeprecationWarning, ) + self._skip_aggregator_types: List[str] = skip_aggregator_types or [] self._text_filters: Sequence[BaseTextFilter] = text_filters or [] self._transport_destination: Optional[str] = transport_destination self._tracing_enabled: bool = False @@ -501,6 +505,12 @@ class TTSService(AIService): type = src_frame.aggregated_by text = src_frame.text + # Skip sending to TTS if the aggregation type is in the skip list. Simply + # push the original frame downstream. + if type in self._skip_aggregator_types: + await self.push_frame(src_frame) + return + # Remove leading newlines only text = text.lstrip("\n")