1616
1717USAGE:
1818 python async_mcp_sample.py
19-
19+
2020 Set the environment variables with your own values before running the sample:
2121 1) AZURE_VOICELIVE_API_KEY - The Azure VoiceLive API key
2222 2) AZURE_VOICELIVE_ENDPOINT - The Azure VoiceLive endpoint
23-
23+
2424REQUIREMENTS:
2525 - azure-ai-voicelive
2626 - python-dotenv
3030import os
3131import sys
3232import asyncio
33- import json
34- import datetime
3533import logging
3634import base64
3735import signal
3836import threading
3937import queue
40- from typing import Union , Optional , Dict , Any , Callable , TYPE_CHECKING , cast
38+ from typing import Union , Optional , Any , Callable , TYPE_CHECKING , cast
4139from concurrent .futures import ThreadPoolExecutor
4240
4341# Audio processing imports
@@ -530,7 +528,7 @@ async def _handle_event(self, event, connection):
530528 await self ._handle_mcp_call_completed (event , connection )
531529 elif event .type == ServerEventType .RESPONSE_MCP_CALL_FAILED :
532530 logger .error (f"MCP call failed for { event .item_id } ." )
533-
531+
534532 elif event .type == ServerEventType .CONVERSATION_ITEM_CREATED :
535533 logger .info (f"Conversation item created: id={ event .item .id } , type={ event .item .type } " )
536534 if event .item .type == ItemType .MCP_LIST_TOOLS :
@@ -602,7 +600,7 @@ async def _handle_mcp_call_completed(self, mcp_call_completed_event: str, connec
602600 return
603601 mcp_output = mcp_call_done .item .output
604602 logger .info (f"MCP Call output received: { mcp_output } " )
605-
603+
606604 # Create a new response to process the MCP output
607605 await connection .response .create ()
608606
@@ -620,7 +618,7 @@ async def _handle_mcp_call_arguments(self, conversation_created_event, connectio
620618 server_label = mcp_call_item .server_label
621619 function_name = mcp_call_item .name
622620 arguments = mcp_call_item .arguments
623-
621+
624622 logger .info (f"MCP Call triggered: server_label={ server_label } , function_name={ function_name } " )
625623 try :
626624 # Wait for the MCP call arguments to be complete
0 commit comments