{
  "schema": "https://ai-atoms.com/schemas/skill-v1.json",
  "type": "skill",
  "id": "skill/azure-ai-voicelive-py",
  "version": "1.0.0",
  "name": "Azure Ai Voicelive Py",
  "description": "Build real-time voice AI applications using Azure AI Voice Live SDK (azure-ai-voicelive). Use this skill when creating Python applications that need real-time bidirectional audio communication with...",
  "system_prompt_fragment": "# Azure AI Voice Live SDK\n\nBuild real-time voice AI applications with bidirectional WebSocket communication.\n\n## Installation\n\n```bash\npip install azure-ai-voicelive aiohttp azure-identity\n```\n\n## Environment Variables\n\n```bash\nAZURE_COGNITIVE_SERVICES_ENDPOINT=https://<region>.api.cognitive.microsoft.com\n# For API key auth (not recommended for production)\nAZURE_COGNITIVE_SERVICES_KEY=<api-key>\n```\n\n## Authentication\n\n**DefaultAzureCredential (preferred)**:\n```python\nfrom azure.ai.voicelive.aio import connect\nfrom azure.identity.aio import DefaultAzureCredential\n\nasync with connect(\n    endpoint=os.environ[\"AZURE_COGNITIVE_SERVICES_ENDPOINT\"],\n    credential=DefaultAzureCredential(),\n    model=\"gpt-4o-realtime-preview\",\n    credential_scopes=[\"https://cognitiveservices.azure.com/.default\"]\n) as conn:\n    ...\n```\n\n**API Key**:\n```python\nfrom azure.ai.voicelive.aio import connect\nfrom azure.core.credentials import AzureKeyCredential\n\nasync with connect(\n    endpoint=os.environ[\"AZURE_COGNITIVE_SERVICES_ENDPOINT\"],\n    credential=AzureKeyCredential(os.environ[\"AZURE_COGNITIVE_SERVICES_KEY\"]),\n    model=\"gpt-4o-realtime-preview\"\n) as conn:\n    ...\n```\n\n## Quick Start\n\n```python\nimport asyncio\nimport os\nfrom azure.ai.voicelive.aio import connect\nfrom azure.identity.aio import DefaultAzureCredential\n\nasync def main():\n    async with connect(\n        endpoint=os.environ[\"AZURE_COGNITIVE_SERVICES_ENDPOINT\"],\n        credential=DefaultAzureCredential(),\n        model=\"gpt-4o-realtime-preview\",\n        credential_scopes=[\"https://cognitiveservices.azure.com/.default\"]\n    ) as conn:\n        # Update session with instructions\n        await conn.session.update(session={\n            \"instructions\": \"You are a helpful assistant.\",\n            \"modalities\": [\"text\", \"audio\"],\n            \"voice\": \"alloy\"\n        })\n        \n        # Listen for events\n        async for event in conn:\n            print(f\"Event: {event.type}\")\n            if event.type == \"response.audio_transcript.done\":\n                print(f\"Transcript: {event.transcript}\")\n            elif event.type == \"response.done\":\n                break\n\nasyncio.run(main())\n```\n\n## Core Architecture\n\n### Connection Resources\n\nThe `VoiceLiveConnection` exposes these resources:\n\n| Resource | Purpose | Key Methods |\n|----------|---------|-------------|\n| `conn.session` | Session configuration | `update(session=...)` |\n| `conn.response` | Model responses | `create()`, `cancel()` |\n| `conn.input_audio_buffer` | Audio input | `append()`, `commit()`, `clear()` |\n| `conn.output_audio_buffer` | Audio output | `clear()` |\n| `conn.conversation` | Conversation state | `item.create()`, `item.delete()`, `item.truncate()` |\n| `conn.transcription_session` | Transcription config | `update(session=...)` |\n\n## Session Configuration\n\n```python\nfrom azure.ai.voicelive.models import RequestSession, FunctionTool\n\nawait conn.session.update(session=RequestSession(\n    instructions=\"You are a helpful voice assistant.\",\n    modalities=[\"text\", \"audio\"],\n    voice=\"alloy\",  # or \"echo\", \"shimmer\", \"sage\", etc.\n    input_audio_format=\"pcm16\",\n    output_audio_format=\"pcm16\",\n    turn_detection={\n        \"type\": \"server_vad\",\n        \"threshold\": 0.5,\n        \"prefix_padding_ms\": 300,\n        \"silence_duration_ms\": 500\n    },\n    tools=[\n        FunctionTool(\n            type=\"function\",\n            name=\"get_weather\",\n            description=\"Get current weather\",\n            parameters={\n                \"type\": \"object\",\n                \"properties\": {\n                    \"location\": {\"type\": \"string\"}\n                },\n                \"required\": [\"location\"]\n            }\n        )\n    ]\n))\n```\n\n## Audio Streaming\n\n### Send Audio (Base64 PCM16)\n\n```python\nimport base64\n\n# Read audio chunk (16-bit PCM, 24kHz mono)\naudio_chunk = await read_audio_from_microphone()\nb64_audio = base64.b64encode(audio_chunk).decode()\n\nawait conn.input_audio_buffer.append(audio=b64_audio)\n```\n\n### Receive Audio\n\n```python\nasync for event in conn:\n    if event.type == \"response.audio.delta\":\n        audio_bytes = base64.b64decode(event.delta)\n        await play_audio(audio_bytes)\n    elif event.type == \"response.audio.done\":\n        print(\"Audio complete\")\n```\n\n## Event Handling\n\n```python\nasync for event in conn:\n    match event.type:\n        # Session events\n        case \"session.created\":\n            print(f\"Session: {event.session}\")\n        case \"session.updated\":\n            print(\"Session updated\")\n        \n        # Audio input events\n        case \"input_audio_buffer.speech_started\":\n            print(f\"Speech started at {event.audio_start_ms}ms\")\n        case \"input_audio_buffer.speech_stopped\":\n            print(f\"Speech stopped at {event.audio_end_ms}ms\")\n        \n        # Transcription events\n        case \"conversation.item.input_audio_transcription.completed\":\n            print(f\"User said: {event.transcript}\")\n        case \"conversation.item.input_audio_transcription.delta\":\n            print(f\"Partial: {event.delta}\")\n        \n        # Response events\n        case \"response.created\":\n            print(f\"Response started: {event.response.id}\")\n        case \"response.audio_transcript.delta\":\n            print(event.delta, end=\"\", flush=True)\n        case \"response.audio.delta\":\n            audio = base64.b64decode(event.delta)\n        case \"response.done\":\n            print(f\"Response complete: {event.response.status}\")\n        \n        # Function calls\n        case \"response.function_call_arguments.done\":\n            result = handle_function(event.name, event.arguments)\n            await conn.conversation.item.create(item={\n                \"type\": \"function_call_output\",\n                \"call_id\": event.call_id,\n                \"output\": json.dumps(result)\n            })\n            await conn.response.create()\n        \n        # Errors\n        case \"error\":\n            print(f\"Error: {event.error.message}\")\n```\n\n## Common Patterns\n\n### Manual Turn Mode (No VAD)\n\n```python\nawait conn.session.update(session={\"turn_detection\": None})\n\n# Manually control turns\nawait conn.input_audio_buffer.append(audio=b64_audio)\nawait conn.input_audio_buffer.commit()  # End of user turn\nawait conn.response.create()  # Trigger response\n```\n\n### Interrupt Handling\n\n```python\nasync for event in conn:\n    if event.type == \"input_audio_buffer.speech_started\":\n        # User interrupted - cancel current response\n        await conn.response.cancel()\n        await conn.output_audio_buffer.clear()\n```\n\n### Conversation History\n\n```python\n# Add system message\nawait conn.conversation.item.create(item={\n    \"type\": \"message\",\n    \"role\": \"system\",\n    \"content\": [{\"type\": \"input_text\", \"text\": \"Be concise.\"}]\n})\n\n# Add user message\nawait conn.conversation.item.create(item={\n    \"type\": \"message\",\n    \"role\": \"user\", \n    \"content\": [{\"type\": \"input_text\", \"text\": \"Hello!\"}]\n})\n\nawait conn.response.create()\n```\n\n## Voice Options\n\n| Voice | Description |\n|-------|-------------|\n| `alloy` | Neutral, balanced |\n| `echo` | Warm, conversational |\n| `shimmer` | Clear, professional |\n| `sage` | Calm, authoritative |\n| `coral` | Friendly, upbeat |\n| `ash` | Deep, measured |\n| `ballad` | Expressive |\n| `verse` | Storytelling |\n\nAzure voices: Use `AzureStandardVoice`, `AzureCustomVoice`, or `AzurePersonalVoice` models.\n\n## Audio Formats\n\n| Format | Sample Rate | Use Case |\n|--------|-------------|----------|\n| `pcm16` | 24kHz | Default, high quality |\n| `pcm16-8000hz` | 8kHz | Telephony |\n| `pcm16-16000hz` | 16kHz | Voice assistants |\n| `g711_ulaw` | 8kHz | Telephony (US) |\n| `g711_alaw` | 8kHz | Telephony (EU) |\n\n## Turn Detection Options\n\n```python\n# Server VAD (default)\n{\"type\": \"server_vad\", \"threshold\": 0.5, \"silence_duration_ms\": 500}\n\n# Azure Semantic VAD (smarter detection)\n{\"type\": \"azure_semantic_vad\"}\n{\"type\": \"azure_semantic_vad_en\"}  # English optimized\n{\"type\": \"azure_semantic_vad_multilingual\"}\n```\n\n## Error Handling\n\n```python\nfrom azure.ai.voicelive.aio import ConnectionError, ConnectionClosed\n\ntry:\n    async with connect(...) as conn:\n        async for event in conn:\n            if event.type == \"error\":\n                print(f\"API Error: {event.error.code} - {event.error.message}\")\nexcept ConnectionClosed as e:\n    print(f\"Connection closed: {e.code} - {e.reason}\")\nexcept ConnectionError as e:\n    print(f\"Connection error: {e}\")\n```\n\n## References\n\n- **Detailed API Reference**: See references/api-reference.md\n- **Complete Examples**: See references/examples.md\n- **All Models & Types**: See references/models.md\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.",
  "applicable_domains": [
    "devops"
  ],
  "category": "devops",
  "invocation": [
    "/azure-ai-voicelive-py"
  ],
  "authored_by": "claudeskills.in community",
  "source_url": "https://claudeskills.in/skill/azure-ai-voicelive-py",
  "provenance": {
    "source": "claudeskills.in",
    "source_url": "https://claudeskills.in/skill/azure-ai-voicelive-py",
    "license": "unknown",
    "imported_at": "2026-09-03",
    "notes": "Aggregated by claudeskills.in from community GitHub lists."
  },
  "tags": [
    "claudeskills",
    "devops"
  ],
  "lifecycle": "draft"
}