AZ

azure-ai-voicelive-dotnet

Enables real-time voice assistant development using Azure AI and .NET. Features bidirectional streaming capabilities.

Install

mkdir -p .claude/skills/azure-ai-voicelive-dotnet && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/13695" && unzip -o skill.zip -d .claude/skills/azure-ai-voicelive-dotnet && rm skill.zip

Installs to .claude/skills/azure-ai-voicelive-dotnet

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Azure AI Voice Live SDK for .NET. Build real-time voice AI applications with bidirectional WebSocket communication.
115 charsno explicit “when” trigger
Intermediate

Key capabilities

  • Start real-time voice AI sessions
  • Configure session options like model and voice
  • Process session update events (audio, text, errors)
  • Send user messages to the AI
  • Implement function calling for external services

How it works

The skill uses the Azure AI Voice Live SDK for .NET to establish a WebSocket connection for real-time voice AI, allowing session configuration, event processing, and bidirectional communication.

Inputs & outputs

You give it
User audio or text messages
You get back
AI-generated audio and text responses, or function call outputs

When to use azure-ai-voicelive-dotnet

  • Build voice assistants
  • Implement real-time audio streaming
  • Configure AI voice sessions
  • Handle bidirectional communication

About this skill

Azure.AI.VoiceLive (.NET)

Real-time voice AI SDK for building bidirectional voice assistants with Azure AI.

Installation

dotnet add package Azure.AI.VoiceLive
dotnet add package Azure.Identity
dotnet add package NAudio                    # For audio capture/playback

Current Versions: Stable v1.0.0, Preview v1.1.0-beta.1

Environment Variables

AZURE_VOICELIVE_ENDPOINT=https://<resource>.services.ai.azure.com/
AZURE_VOICELIVE_MODEL=gpt-4o-realtime-preview
AZURE_VOICELIVE_VOICE=en-US-AvaNeural
# Optional: API key if not using Entra ID
AZURE_VOICELIVE_API_KEY=<your-api-key>

Authentication

Microsoft Entra ID (Recommended)

using Azure.Identity;
using Azure.AI.VoiceLive;

Uri endpoint = new Uri("https://your-resource.cognitiveservices.azure.com");
DefaultAzureCredential credential = new DefaultAzureCredential();
VoiceLiveClient client = new VoiceLiveClient(endpoint, credential);

Required Role: Cognitive Services User (assign in Azure Portal → Access control)

API Key

Uri endpoint = new Uri("https://your-resource.cognitiveservices.azure.com");
AzureKeyCredential credential = new AzureKeyCredential("your-api-key");
VoiceLiveClient client = new VoiceLiveClient(endpoint, credential);

Client Hierarchy

VoiceLiveClient
└── VoiceLiveSession (WebSocket connection)
    ├── ConfigureSessionAsync()
    ├── GetUpdatesAsync() → SessionUpdate events
    ├── AddItemAsync() → UserMessageItem, FunctionCallOutputItem
    ├── SendAudioAsync()
    └── StartResponseAsync()

Core Workflow

1. Start Session and Configure

using Azure.Identity;
using Azure.AI.VoiceLive;

var endpoint = new Uri(Environment.GetEnvironmentVariable("AZURE_VOICELIVE_ENDPOINT"));
var client = new VoiceLiveClient(endpoint, new DefaultAzureCredential());

var model = "gpt-4o-mini-realtime-preview";

// Start session
using VoiceLiveSession session = await client.StartSessionAsync(model);

// Configure session
VoiceLiveSessionOptions sessionOptions = new()
{
    Model = model,
    Instructions = "You are a helpful AI assistant. Respond naturally.",
    Voice = new AzureStandardVoice("en-US-AvaNeural"),
    TurnDetection = new AzureSemanticVadTurnDetection()
    {
        Threshold = 0.5f,
        PrefixPadding = TimeSpan.FromMilliseconds(300),
        SilenceDuration = TimeSpan.FromMilliseconds(500)
    },
    InputAudioFormat = InputAudioFormat.Pcm16,
    OutputAudioFormat = OutputAudioFormat.Pcm16
};

// Set modalities (both text and audio for voice assistants)
sessionOptions.Modalities.Clear();
sessionOptions.Modalities.Add(InteractionModality.Text);
sessionOptions.Modalities.Add(InteractionModality.Audio);

await session.ConfigureSessionAsync(sessionOptions);

2. Process Events

await foreach (SessionUpdate serverEvent in session.GetUpdatesAsync())
{
    switch (serverEvent)
    {
        case SessionUpdateResponseAudioDelta audioDelta:
            byte[] audioData = audioDelta.Delta.ToArray();
            // Play audio via NAudio or other audio library
            break;
            
        case SessionUpdateResponseTextDelta textDelta:
            Console.Write(textDelta.Delta);
            break;
            
        case SessionUpdateResponseFunctionCallArgumentsDone functionCall:
            // Handle function call (see Function Calling section)
            break;
            
        case SessionUpdateError error:
            Console.WriteLine($"Error: {error.Error.Message}");
            break;
            
        case SessionUpdateResponseDone:
            Console.WriteLine("\n--- Response complete ---");
            break;
    }
}

3. Send User Message

await session.AddItemAsync(new UserMessageItem("Hello, can you help me?"));
await session.StartResponseAsync();

4. Function Calling

// Define function
var weatherFunction = new VoiceLiveFunctionDefinition("get_current_weather")
{
    Description = "Get the current weather for a given location",
    Parameters = BinaryData.FromString("""
        {
            "type": "object",
            "properties": {
                "location": {
                    "type": "string",
                    "description": "The city and state or country"
                }
            },
            "required": ["location"]
        }
        """)
};

// Add to session options
sessionOptions.Tools.Add(weatherFunction);

// Handle function call in event loop
if (serverEvent is SessionUpdateResponseFunctionCallArgumentsDone functionCall)
{
    if (functionCall.Name == "get_current_weather")
    {
        var parameters = JsonSerializer.Deserialize<Dictionary<string, string>>(functionCall.Arguments);
        string location = parameters?["location"] ?? "";
        
        // Call external service
        string weatherInfo = $"The weather in {location} is sunny, 75°F.";
        
        // Send response
        await session.AddItemAsync(new FunctionCallOutputItem(functionCall.CallId, weatherInfo));
        await session.StartResponseAsync();
    }
}

Voice Options

Voice TypeClassExample
Azure StandardAzureStandardVoice"en-US-AvaNeural"
Azure HDAzureStandardVoice"en-US-Ava:DragonHDLatestNeural"
Azure CustomAzureCustomVoiceCustom voice with endpoint ID

Supported Models

ModelDescription
gpt-4o-realtime-previewGPT-4o with real-time audio
gpt-4o-mini-realtime-previewLightweight, fast interactions
phi4-mm-realtimeCost-effective multimodal

Key Types Reference

TypePurpose
VoiceLiveClientMain client for creating sessions
VoiceLiveSessionActive WebSocket session
VoiceLiveSessionOptionsSession configuration
AzureStandardVoiceStandard Azure voice provider
AzureSemanticVadTurnDetectionVoice activity detection
VoiceLiveFunctionDefinitionFunction tool definition
UserMessageItemUser text message
FunctionCallOutputItemFunction call response
SessionUpdateResponseAudioDeltaAudio chunk event
SessionUpdateResponseTextDeltaText chunk event

Best Practices

  1. Always set both modalities — Include Text and Audio for voice assistants
  2. Use AzureSemanticVadTurnDetection — Provides natural conversation flow
  3. Configure appropriate silence duration — 500ms typical to avoid premature cutoffs
  4. Use using statement — Ensures proper session disposal
  5. Handle all event types — Check for errors, audio, text, and function calls
  6. Use DefaultAzureCredential — Never hardcode API keys

Error Handling

if (serverEvent is SessionUpdateError error)
{
    if (error.Error.Message.Contains("Cancellation failed: no active response"))
    {
        // Benign error, can ignore
    }
    else
    {
        Console.WriteLine($"Error: {error.Error.Message}");
    }
}

Audio Configuration

  • Input Format: InputAudioFormat.Pcm16 (16-bit PCM)
  • Output Format: OutputAudioFormat.Pcm16
  • Sample Rate: 24kHz recommended
  • Channels: Mono

Related SDKs

SDKPurposeInstall
Azure.AI.VoiceLiveReal-time voice (this SDK)dotnet add package Azure.AI.VoiceLive
Microsoft.CognitiveServices.SpeechSpeech-to-text, text-to-speechdotnet add package Microsoft.CognitiveServices.Speech
NAudioAudio capture/playbackdotnet add package NAudio

Reference Links

ResourceURL
NuGet Packagehttps://www.nuget.org/packages/Azure.AI.VoiceLive
API Referencehttps://learn.microsoft.com/dotnet/api/azure.ai.voicelive
GitHub Sourcehttps://github.com/Azure/azure-sdk-for-net/tree/main/sdk/ai/Azure.AI.VoiceLive
Quickstarthttps://learn.microsoft.com/azure/ai-services/speech-service/voice-live-quickstart

When to Use

This skill is applicable to execute the workflow or actions described in the overview.

When not to use it

  • When the application does not require real-time bidirectional WebSocket communication
  • When not interacting with Azure AI Voice Live

Prerequisites

AZURE_VOICELIVE_ENDPOINT environment variableAZURE_VOICELIVE_MODEL environment variableAZURE_VOICELIVE_VOICE environment variableCognitive Services User role

Limitations

  • Requires `Cognitive Services User` role for authentication
  • Requires `InputAudioFormat.Pcm16` and `OutputAudioFormat.Pcm16` for audio
  • Requires handling all event types for complete interaction

How it compares

This SDK provides a structured way to build real-time voice assistants with Azure AI, handling audio streaming and function calls over WebSockets, unlike simpler text-based AI interactions.

Compared to similar skills

azure-ai-voicelive-dotnet side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
azure-ai-voicelive-dotnet (this skill)04moReviewIntermediate
dotnet-backend-patterns75moNo flagsAdvanced
azure-servicebus-dotnet33moReviewIntermediate
azure-eventgrid-dotnet13moReviewIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

dotnet-backend-patterns

wshobson

Master C#/.NET backend development patterns for building robust APIs, MCP servers, and enterprise applications. Covers async/await, dependency injection, Entity Framework Core, Dapper, configuration, caching, and testing with xUnit. Use when developing .NET backends, reviewing C# code, or designing API architectures.

722

azure-servicebus-dotnet

microsoft

Azure Service Bus SDK for .NET. Enterprise messaging with queues, topics, subscriptions, and sessions. Use for reliable message delivery, pub/sub patterns, dead letter handling, and background processing. Triggers: "Service Bus", "ServiceBusClient", "ServiceBusSender", "ServiceBusReceiver", "ServiceBusProcessor", "message queue", "pub/sub .NET", "dead letter queue".

316

azure-eventgrid-dotnet

microsoft

Azure Event Grid SDK for .NET. Client library for publishing and consuming events with Azure Event Grid. Use for event-driven architectures, pub/sub messaging, CloudEvents, and EventGridEvents. Triggers: "Event Grid", "EventGridPublisherClient", "CloudEvent", "EventGridEvent", "publish events .NET", "event-driven", "pub/sub".

11

websocket-integration

sunyonghuan

通过 WebSocket 连接 Cortana AI 对话服务。编写 C# 客户端代码,实现发送消息、接收流式回复、附件传输、系统事件监听。触发关键词:WebSocket、WS 连接、远程对话、流式回复、AI 接入、实时通信。

00

mediatorlite-core

behl1anmol

Runtime implementation for MediatorLite -- AddMediatorLite() DI extension, the ThrowingMediator diagnostic fallback, the generated SourceGeneratedMediator (implements IMediator via ValueTask typed-switch dispatch), MediatorDiagnostics (ActivitySource + DiagnosticListener), and the Validation subsyst

00

cqrs-feature

FlorianDrevet

Use when touching backend feature slices in the .NET CQRS stack of this repository.

00

Search skills

Search the agent skills registry