@@ -162,6 +162,7 @@ async def simple_audio_response(self, pcm: PcmData):
162162 if not self .connected :
163163 self .logger .warning ("realtime is not active. can't call simple_audio_response" )
164164
165+ logger .info ("sar" )
165166 #self.logger.info("Simple audio response for model %s", self.model)
166167 content_name = str (uuid .uuid4 ())
167168 audio_bytes = pcm
@@ -354,6 +355,7 @@ async def _handle_events(self):
354355 result = await output [1 ].receive ()
355356 if result .value and result .value .bytes_ :
356357 try :
358+ logger .info ("received..." )
357359 response_data = result .value .bytes_ .decode ('utf-8' )
358360 json_data = json .loads (response_data )
359361
@@ -382,18 +384,21 @@ async def _handle_events(self):
382384 logger .info ("Completion start from Bedrock" , json_data ['event' ]['completionStart' ])
383385 elif 'audioOutput' in json_data ['event' ]:
384386 logger .info ("Audio output from Bedrock" )
385- audio_content = json_data ['event' ]['audioOutput' ]['content' ]
386- audio_bytes = base64 .b64decode (audio_content )
387- #await self.audio_output_queue.put(audio_bytes)
388-
389- audio_event = RealtimeAudioOutputEvent (
390- plugin_name = "gemini" ,
391- audio_data = audio_content ,
392- sample_rate = 24000
393- )
394- self .events .send (audio_event )
395-
396- await self .output_track .write (audio_content )
387+ try :
388+ audio_content = json_data ['event' ]['audioOutput' ]['content' ]
389+ audio_bytes = base64 .b64decode (audio_content )
390+ #await self.audio_output_queue.put(audio_bytes)
391+
392+ audio_event = RealtimeAudioOutputEvent (
393+ plugin_name = "gemini" ,
394+ audio_data = audio_bytes ,
395+ sample_rate = 24000
396+ )
397+ self .events .send (audio_event )
398+
399+ await self .output_track .write (audio_bytes )
400+ except Exception as e :
401+ import pdb ; pdb .set_trace ()
397402
398403 elif 'toolUse' in json_data ['event' ]:
399404 logger .info (f"Tool use from Bedrock: { json_data ['event' ]['toolUse' ]} " )
0 commit comments