Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion speech-to-speech/workshops/python-server/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ websockets==15.0.1
aws_sdk_bedrock_runtime
mcp==1.8.1
strands-agents
requests=2.32.3
requests==2.32.3
9 changes: 6 additions & 3 deletions speech-to-speech/workshops/python-server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ async def websocket_handler(websocket):
if not aws_region:
aws_region = "us-east-1"

event_type = None
forward_task = None
stream_manager = None
try:
async for message in websocket:
Expand Down Expand Up @@ -158,7 +160,8 @@ async def websocket_handler(websocket):
finally:
# Clean up
await stream_manager.close()
forward_task.cancel()
if forward_task:
forward_task.cancel()
if websocket:
websocket.close()
if MCP_CLIENT:
Expand Down Expand Up @@ -248,8 +251,8 @@ async def main(host, port, health_port, enable_mcp=False, enable_strands_agent=F

if not host or not port:
print(f"HOST and PORT are required. Received HOST: {host}, PORT: {port}")
elif not aws_key_id or not aws_secret:
print(f"AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are required.")
# elif not aws_key_id or not aws_secret:
# print(f"AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are required.")
else:
try:
asyncio.run(main(host, port, health_port, enable_mcp, enable_strands))
Expand Down