From 5e0803479ea04fbb40f7f80d398165f6e2b50380 Mon Sep 17 00:00:00 2001 From: Paul Kompfner Date: Wed, 30 Apr 2025 14:53:22 -0400 Subject: [PATCH] [WIP] AWS Nova Sonic service - add send_transcription_frames option --- src/pipecat/services/aws_nova_sonic/aws.py | 10 +++++++--- src/pipecat/services/aws_nova_sonic/context.py | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/pipecat/services/aws_nova_sonic/aws.py b/src/pipecat/services/aws_nova_sonic/aws.py index 1b2937f83..3c6de7ad7 100644 --- a/src/pipecat/services/aws_nova_sonic/aws.py +++ b/src/pipecat/services/aws_nova_sonic/aws.py @@ -118,6 +118,7 @@ class AWSNovaSonicLLMService(LLMService): voice_id: str = "matthew", # matthew, tiffany, amy instruction: Optional[str] = None, tools: Optional[ToolsSchema] = None, + send_transcription_frames: bool = True, **kwargs, ): super().__init__(**kwargs) @@ -129,6 +130,7 @@ class AWSNovaSonicLLMService(LLMService): self._voice_id = voice_id self._instruction = instruction self._tools = tools + self._send_transcription_frames = send_transcription_frames self._context: AWSNovaSonicLLMContext = None self._stream: DuplexEventStream[ InvokeModelWithBidirectionalStreamInput, @@ -802,10 +804,12 @@ class AWSNovaSonicLLMService(LLMService): # Manually add new user transcription text to context. # We can't rely on the user context aggregator to do this since it's upstream from the LLM. self._context.add_user_transcription_text_as_message(text) + # Report that some new user transcription text is available. - await self.push_frame( - TranscriptionFrame(text=text, user_id="", timestamp=time_now_iso8601()) - ) + if self._send_transcription_frames: + await self.push_frame( + TranscriptionFrame(text=text, user_id="", timestamp=time_now_iso8601()) + ) # # Context diff --git a/src/pipecat/services/aws_nova_sonic/context.py b/src/pipecat/services/aws_nova_sonic/context.py index 206c1fd2b..e4662ee57 100644 --- a/src/pipecat/services/aws_nova_sonic/context.py +++ b/src/pipecat/services/aws_nova_sonic/context.py @@ -94,11 +94,11 @@ class AWSNovaSonicLLMContext(OpenAILLMContext): f"Unhandled content type in context message: {c.get('type')} - {message}" ) # There won't be content if this is an assistant tool call entry. - # We're ignoring those since they can't be loaded into AWS Nova Sonic conversation + # We're ignoring those since they can't be loaded into AWS Nova Sonic conversation # history if content: return AWSNovaSonicConversationHistoryMessage(role=Role[role.upper()], text=content) - # We're ignoring messages with role "tool" since they can't be loaded into AWS Nova Sonic + # We're ignoring messages with role "tool" since they can't be loaded into AWS Nova Sonic # conversation history logger.error(f"Unhandled message type in from_standard_message: {message}")