{"slug":"azure-ai-voicelive-dotnet","title":"azure-ai-voicelive-dotnet","summary":"Azure AI Voice Live SDK for .NET. Build real-time voice AI applications with bidirectional WebSocket communication. Use for voice assistants, conversational AI, real-time speech-to-speech, and voice-enabled chatbots. Triggers: \"voice live\", \"real-time voice\", \"VoiceLiveClient\", \"","platform":"GitHub Copilot","tags":[],"authorName":"Ciza","authorSlug":"ciza","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-08-12T21:05:11.97598Z","repo":{"url":"https://github.com/microsoft/skills","stars":3226,"forks":373,"license":"MIT","updatedAt":"2026-11-19T11:04:16Z"},"bodyHtml":"<hr>\n<h2>name: azure-ai-voicelive-dotnet\ndescription: |\nAzure AI Voice Live SDK for .NET. Build real-time voice AI applications with bidirectional WebSocket communication. Use for voice assistants, conversational AI, real-time speech-to-speech, and voice-enabled chatbots. Triggers: \"voice live\", \"real-time voice\", \"VoiceLiveClient\", \"VoiceLiveSession\", \"voice assistant .NET\", \"bidirectional audio\", \"speech-to-speech\".\nlicense: MIT\nmetadata:\nauthor: Microsoft\nversion: \"1.0.0\"\npackage: Azure.AI.VoiceLive</h2>\n<h1>Azure.AI.VoiceLive (.NET)</h1>\n<p>Real-time voice AI SDK for building bidirectional voice assistants with Azure AI.</p>\n<h2>Installation</h2>\n<pre><code>dotnet add package Azure.AI.VoiceLive\ndotnet add package Azure.Identity\ndotnet add package NAudio                    # For audio capture/playback\n</code></pre>\n<p><strong>Current Versions</strong>: Stable v1.0.0, Preview v1.1.0-beta.1</p>\n<h2>Environment Variables</h2>\n<pre><code>AZURE_VOICELIVE_ENDPOINT=https://&lt;resource&gt;.services.ai.azure.com/  # Required: Voice Live endpoint\nAZURE_VOICELIVE_MODEL=gpt-4o-realtime-preview  # Required: model deployment name\nAZURE_VOICELIVE_VOICE=en-US-AvaNeural  # Optional: Voice Live voice name\nAZURE_VOICELIVE_API_KEY=&lt;your-api-key&gt;  # Only required for AzureKeyCredential auth\nAZURE_TOKEN_CREDENTIALS=prod  # Required only if DefaultAzureCredential is used in production\n</code></pre>\n<h2>Authentication</h2>\n<h3>Microsoft Entra Token Credential</h3>\n<pre><code>using Azure.Identity;\nusing Azure.AI.VoiceLive;\n\nUri endpoint = new Uri(\"https://your-resource.cognitiveservices.azure.com\");\n// Local dev: DefaultAzureCredential. Production: set AZURE_TOKEN_CREDENTIALS=prod or AZURE_TOKEN_CREDENTIALS=&lt;specific_credential&gt;\nvar credential = new DefaultAzureCredential(\n    DefaultAzureCredential.DefaultEnvironmentVariableName\n);\n// Or use a specific credential directly in production:\n// See https://learn.microsoft.com/dotnet/api/overview/azure/identity-readme?view=azure-dotnet#credential-classes\n// var credential = new ManagedIdentityCredential();\nVoiceLiveClient client = new VoiceLiveClient(endpoint, credential);\n</code></pre>\n<p><strong>Required Role</strong>: <code>Cognitive Services User</code> (assign in Azure Portal → Access control)</p>\n<h3>API Key</h3>\n<pre><code>Uri endpoint = new Uri(\"https://your-resource.cognitiveservices.azure.com\");\nAzureKeyCredential credential = new AzureKeyCredential(\"your-api-key\");\nVoiceLiveClient client = new VoiceLiveClient(endpoint, credential);\n</code></pre>\n<h2>Client Hierarchy</h2>\n<pre><code>VoiceLiveClient\n└── VoiceLiveSession (WebSocket connection)\n    ├── ConfigureSessionAsync()\n    ├── GetUpdatesAsync() → SessionUpdate events\n    ├── AddItemAsync() → UserMessageItem, FunctionCallOutputItem\n    ├── SendAudioAsync()\n    └── StartResponseAsync()\n</code></pre>\n<h2>Core Workflow</h2>\n<h3>1. Start Session and Configure</h3>\n<pre><code>using Azure.Identity;\nusing Azure.AI.VoiceLive;\n\nvar endpoint = new Uri(Environment.GetEnvironmentVariable(\"AZURE_VOICELIVE_ENDPOINT\"));\nvar client = new VoiceLiveClient(endpoint, new DefaultAzureCredential());\n\nvar model = \"gpt-4o-mini-realtime-preview\";\n\n// Start session\nusing VoiceLiveSession session = await client.StartSessionAsync(model);\n\n// Configure session\nVoiceLiveSessionOptions sessionOptions = new()\n{\n    Model = model,\n    Instructions = \"You are a helpful AI assistant. Respond naturally.\",\n    Voice = new AzureStandardVoice(\"en-US-AvaNeural\"),\n    TurnDetection = new AzureSemanticVadTurnDetection()\n    {\n        Threshold = 0.5f,\n        PrefixPadding = TimeSpan.FromMilliseconds(300),\n        SilenceDuration = TimeSpan.FromMilliseconds(500)\n    },\n    InputAudioFormat = InputAudioFormat.Pcm16,\n    OutputAudioFormat = OutputAudioFormat.Pcm16\n};\n\n// Set modalities (both text and audio for voice assistants)\nsessionOptions.Modalities.Clear();\nsessionOptions.Modalities.Add(InteractionModality.Text);\nsessionOptions.Modalities.Add(InteractionModality.Audio);\n\nawait session.ConfigureSessionAsync(sessionOptions);\n</code></pre>\n<h3>2. Process Events</h3>\n<pre><code>await foreach (SessionUpdate serverEvent in session.GetUpdatesAsync())\n{\n    switch (serverEvent)\n    {\n        case SessionUpdateResponseAudioDelta audioDelta:\n            byte[] audioData = audioDelta.Delta.ToArray();\n            // Play audio via NAudio or other audio library\n            break;\n            \n        case SessionUpdateResponseTextDelta textDelta:\n            Console.Write(textDelta.Delta);\n            break;\n            \n        case SessionUpdateResponseFunctionCallArgumentsDone functionCall:\n            // Handle function call (see Function Calling section)\n            break;\n            \n        case SessionUpdateError error:\n            Console.WriteLine($\"Error: {error.Error.Message}\");\n            break;\n            \n        case SessionUpdateResponseDone:\n            Console.WriteLine(\"\\n--- Response complete ---\");\n            break;\n    }\n}\n</code></pre>\n<h3>3. Send User Message</h3>\n<pre><code>await session.AddItemAsync(new UserMessageItem(\"Hello, can you help me?\"));\nawait session.StartResponseAsync();\n</code></pre>\n<h3>4. Function Calling</h3>\n<pre><code>// Define function\nvar weatherFunction = new VoiceLiveFunctionDefinition(\"get_current_weather\")\n{\n    Description = \"Get the current weather for a given location\",\n    Parameters = BinaryData.FromString(\"\"\"\n        {\n            \"type\": \"object\",\n            \"properties\": {\n                \"location\": {\n                    \"type\": \"string\",\n                    \"description\": \"The city and state or country\"\n                }\n            },\n            \"required\": [\"location\"]\n        }\n        \"\"\")\n};\n\n// Add to session options\nsessionOptions.Tools.Add(weatherFunction);\n\n// Handle function call in event loop\nif (serverEvent is SessionUpdateResponseFunctionCallArgumentsDone functionCall)\n{\n    if (functionCall.Name == \"get_current_weather\")\n    {\n        var parameters = JsonSerializer.Deserialize&lt;Dictionary&lt;string, string&gt;&gt;(functionCall.Arguments);\n        string location = parameters?[\"location\"] ?? \"\";\n        \n        // Call external service\n        string weatherInfo = $\"The weather in {location} is sunny, 75°F.\";\n        \n        // Send response\n        await session.AddItemAsync(new FunctionCallOutputItem(functionCall.CallId, weatherInfo));\n        await session.StartResponseAsync();\n    }\n}\n</code></pre>\n<h2>Voice Options</h2>\n<table>\n<thead>\n<tr>\n<th>Voice Type</th>\n<th>Class</th>\n<th>Example</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Azure Standard</td>\n<td><code>AzureStandardVoice</code></td>\n<td><code>\"en-US-AvaNeural\"</code></td>\n</tr>\n<tr>\n<td>Azure HD</td>\n<td><code>AzureStandardVoice</code></td>\n<td><code>\"en-US-Ava:DragonHDLatestNeural\"</code></td>\n</tr>\n<tr>\n<td>Azure Custom</td>\n<td><code>AzureCustomVoice</code></td>\n<td>Custom voice with endpoint ID</td>\n</tr>\n</tbody>\n</table>\n<h2>Supported Models</h2>\n<table>\n<thead>\n<tr>\n<th>Model</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>gpt-4o-realtime-preview</code></td>\n<td>GPT-4o with real-time audio</td>\n</tr>\n<tr>\n<td><code>gpt-4o-mini-realtime-preview</code></td>\n<td>Lightweight, fast interactions</td>\n</tr>\n<tr>\n<td><code>phi4-mm-realtime</code></td>\n<td>Cost-effective multimodal</td>\n</tr>\n</tbody>\n</table>\n<h2>Key Types Reference</h2>\n<table>\n<thead>\n<tr>\n<th>Type</th>\n<th>Purpose</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>VoiceLiveClient</code></td>\n<td>Main client for creating sessions</td>\n</tr>\n<tr>\n<td><code>VoiceLiveSession</code></td>\n<td>Active WebSocket session</td>\n</tr>\n<tr>\n<td><code>VoiceLiveSessionOptions</code></td>\n<td>Session configuration</td>\n</tr>\n<tr>\n<td><code>AzureStandardVoice</code></td>\n<td>Standard Azure voice provider</td>\n</tr>\n<tr>\n<td><code>AzureSemanticVadTurnDetection</code></td>\n<td>Voice activity detection</td>\n</tr>\n<tr>\n<td><code>VoiceLiveFunctionDefinition</code></td>\n<td>Function tool definition</td>\n</tr>\n<tr>\n<td><code>UserMessageItem</code></td>\n<td>User text message</td>\n</tr>\n<tr>\n<td><code>FunctionCallOutputItem</code></td>\n<td>Function call response</td>\n</tr>\n<tr>\n<td><code>SessionUpdateResponseAudioDelta</code></td>\n<td>Audio chunk event</td>\n</tr>\n<tr>\n<td><code>SessionUpdateResponseTextDelta</code></td>\n<td>Text chunk event</td>\n</tr>\n</tbody>\n</table>\n<h2>Best Practices</h2>\n<ol>\n<li><strong>Always set both modalities</strong> — Include <code>Text</code> and <code>Audio</code> for voice assistants</li>\n<li><strong>Use <code>AzureSemanticVadTurnDetection</code></strong> — Provides natural conversation flow</li>\n<li><strong>Configure appropriate silence duration</strong> — 500ms typical to avoid premature cutoffs</li>\n<li><strong>Use <code>using</code> statement</strong> — Ensures proper session disposal</li>\n<li><strong>Handle all event types</strong> — Check for errors, audio, text, and function calls</li>\n<li><strong>Use DefaultAzureCredential</strong> — Never hardcode API keys</li>\n</ol>\n<h2>Error Handling</h2>\n<pre><code>if (serverEvent is SessionUpdateError error)\n{\n    if (error.Error.Message.Contains(\"Cancellation failed: no active response\"))\n    {\n        // Benign error, can ignore\n    }\n    else\n    {\n        Console.WriteLine($\"Error: {error.Error.Message}\");\n    }\n}\n</code></pre>\n<h2>Audio Configuration</h2>\n<ul>\n<li><strong>Input Format</strong>: <code>InputAudioFormat.Pcm16</code> (16-bit PCM)</li>\n<li><strong>Output Format</strong>: <code>OutputAudioFormat.Pcm16</code></li>\n<li><strong>Sample Rate</strong>: 24kHz recommended</li>\n<li><strong>Channels</strong>: Mono</li>\n</ul>\n<h2>Related SDKs</h2>\n<table>\n<thead>\n<tr>\n<th>SDK</th>\n<th>Purpose</th>\n<th>Install</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>Azure.AI.VoiceLive</code></td>\n<td>Real-time voice (this SDK)</td>\n<td><code>dotnet add package Azure.AI.VoiceLive</code></td>\n</tr>\n<tr>\n<td><code>Microsoft.CognitiveServices.Speech</code></td>\n<td>Speech-to-text, text-to-speech</td>\n<td><code>dotnet add package Microsoft.CognitiveServices.Speech</code></td>\n</tr>\n<tr>\n<td><code>NAudio</code></td>\n<td>Audio capture/playback</td>\n<td><code>dotnet add package NAudio</code></td>\n</tr>\n</tbody>\n</table>\n<h2>Reference Links</h2>\n<table>\n<thead>\n<tr>\n<th>Resource</th>\n<th>URL</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>NuGet Package</td>\n<td><a href=\"https://www.nuget.org/packages/Azure.AI.VoiceLive\">https://www.nuget.org/packages/Azure.AI.VoiceLive</a></td>\n</tr>\n<tr>\n<td>API Reference</td>\n<td><a href=\"https://learn.microsoft.com/dotnet/api/azure.ai.voicelive\">https://learn.microsoft.com/dotnet/api/azure.ai.voicelive</a></td>\n</tr>\n<tr>\n<td>GitHub Source</td>\n<td><a href=\"https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/ai/Azure.AI.VoiceLive\">https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/ai/Azure.AI.VoiceLive</a></td>\n</tr>\n<tr>\n<td>Quickstart</td>\n<td><a href=\"https://learn.microsoft.com/azure/ai-services/speech-service/voice-live-quickstart\">https://learn.microsoft.com/azure/ai-services/speech-service/voice-live-quickstart</a></td>\n</tr>\n</tbody>\n</table>\n","files":[{"path":"SKILL.md","sizeBytes":9165,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-08-12T21:50:42.48626Z","sha256":"0E02C17B6F39504E2A86D2E304EF2A870A274CC4FD36A5C2F9322840A338AD2D","sizeBytes":3358},"review":null,"source":{"repositoryUrl":"https://github.com/microsoft/skills","path":".github/plugins/azure-sdk-dotnet/skills/azure-ai-voicelive-dotnet","license":"MIT","commit":"b35d2c60fac796bfd2cfd14ad3f550c73e92d9bb","subtreeSha":"80F9812DFAC4837076B3AFB52C20D416A65722585D2007FA65E971CC20272DD4","lastSyncedAt":"2026-11-19T20:53:05.968523Z"},"reviewedAt":"2026-08-12T21:54:21.77984Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-dotnet/skills/azure-ai-voicelive-dotnet"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install microsoft-skills@llmmart"},{"target":"git","command":"git clone https://github.com/microsoft/skills.git"}]}