Skip to content

Commit a310771

Browse files
committed
wip
1 parent b4370f4 commit a310771

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

examples/other_examples/bedrock_nova/bedrock_qwen_example.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from vision_agents.core import User
88
from vision_agents.core.agents import Agent
9-
from vision_agents.plugins import bedrock, getstream
9+
from vision_agents.plugins import bedrock, getstream, cartesia, deepgram, smart_turn
1010

1111
load_dotenv()
1212

@@ -20,6 +20,10 @@ async def start_agent() -> None:
2020
agent_user=User(name="Friendly AI"),
2121
instructions="Be nice to the user",
2222
llm=bedrock.LLM(model="anthropic.claude-3-5-sonnet-20241022-v2:0"),
23+
tts=cartesia.TTS(),
24+
stt=deepgram.STT(),
25+
turn_detection=smart_turn.TurnDetection(buffer_duration=2.0, confidence_threshold=0.5),
26+
# Enable turn detection with FAL/ Smart turn
2327
)
2428
await agent.create_user()
2529

@@ -29,6 +33,7 @@ async def start_agent() -> None:
2933
with await agent.join(call):
3034
await asyncio.sleep(5)
3135
await agent.llm.simple_response(text="Say hi")
36+
await agent.finish()
3237

3338

3439
if __name__ == "__main__":

plugins/bedrock/vision_agents/plugins/bedrock/bedrock_realtime.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)