Added support to TTS services to skip sending text to the...
the actual TTS service to be spoken based on its aggregation type.
This commit is contained in:
committed by
Mattie Ruth
parent
6b6d760cf1
commit
e1528d0f0c
@@ -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
|
encompassing text should be added to the LLM context (by the LLM assistant aggregator). It
|
||||||
defaults to `True`.
|
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
|
### Deprecated
|
||||||
|
|
||||||
- The `api_key` parameter in `GeminiTTSService` is deprecated. Use
|
- The `api_key` parameter in `GeminiTTSService` is deprecated. Use
|
||||||
|
|||||||
@@ -103,6 +103,8 @@ class TTSService(AIService):
|
|||||||
sample_rate: Optional[int] = None,
|
sample_rate: Optional[int] = None,
|
||||||
# Text aggregator to aggregate incoming tokens and decide when to push to the TTS.
|
# Text aggregator to aggregate incoming tokens and decide when to push to the TTS.
|
||||||
text_aggregator: Optional[BaseTextAggregator] = None,
|
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 filter executed after text has been aggregated.
|
||||||
text_filters: Optional[Sequence[BaseTextFilter]] = None,
|
text_filters: Optional[Sequence[BaseTextFilter]] = None,
|
||||||
text_filter: Optional[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.
|
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.
|
pause_frame_processing: Whether to pause frame processing during audio generation.
|
||||||
sample_rate: Output sample rate for generated audio.
|
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.
|
text_aggregator: Custom text aggregator for processing incoming text.
|
||||||
|
|
||||||
.. deprecated:: 0.0.95
|
.. deprecated:: 0.0.95
|
||||||
@@ -158,6 +161,7 @@ class TTSService(AIService):
|
|||||||
DeprecationWarning,
|
DeprecationWarning,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self._skip_aggregator_types: List[str] = skip_aggregator_types or []
|
||||||
self._text_filters: Sequence[BaseTextFilter] = text_filters or []
|
self._text_filters: Sequence[BaseTextFilter] = text_filters or []
|
||||||
self._transport_destination: Optional[str] = transport_destination
|
self._transport_destination: Optional[str] = transport_destination
|
||||||
self._tracing_enabled: bool = False
|
self._tracing_enabled: bool = False
|
||||||
@@ -501,6 +505,12 @@ class TTSService(AIService):
|
|||||||
type = src_frame.aggregated_by
|
type = src_frame.aggregated_by
|
||||||
text = src_frame.text
|
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
|
# Remove leading newlines only
|
||||||
text = text.lstrip("\n")
|
text = text.lstrip("\n")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user