[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-2c26ca58-3cf8-497e-b103-4022cac78cfe":3,"$fcde_iblb7YTit42XySChO36xSOhr3-qeyyBgFwfXaXg":43},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":34},"2c26ca58-3cf8-497e-b103-4022cac78cfe","azure-ai-voicelive-dotnet","Azure AI语音实时SDK for .NET。使用双向WebSocket通信构建实时语音AI应用。","cat_coding_devops","mod_coding","sickn33,coding","---\nname: azure-ai-voicelive-dotnet\ndescription: Azure AI Voice Live SDK for .NET. Build real-time voice AI applications with bidirectional WebSocket communication.\nrisk: unknown\nsource: community\ndate_added: '2026-02-27'\n---\n\n# Azure.AI.VoiceLive (.NET)\n\nReal-time voice AI SDK for building bidirectional voice assistants with Azure AI.\n\n## Installation\n\n```bash\ndotnet add package Azure.AI.VoiceLive\ndotnet add package Azure.Identity\ndotnet add package NAudio                    # For audio capture\u002Fplayback\n```\n\n**Current Versions**: Stable v1.0.0, Preview v1.1.0-beta.1\n\n## Environment Variables\n\n```bash\nAZURE_VOICELIVE_ENDPOINT=https:\u002F\u002F\u003Cresource>.services.ai.azure.com\u002F\nAZURE_VOICELIVE_MODEL=gpt-4o-realtime-preview\nAZURE_VOICELIVE_VOICE=en-US-AvaNeural\n# Optional: API key if not using Entra ID\nAZURE_VOICELIVE_API_KEY=\u003Cyour-api-key>\n```\n\n## Authentication\n\n### Microsoft Entra ID (Recommended)\n\n```csharp\nusing Azure.Identity;\nusing Azure.AI.VoiceLive;\n\nUri endpoint = new Uri(\"https:\u002F\u002Fyour-resource.cognitiveservices.azure.com\");\nDefaultAzureCredential credential = new DefaultAzureCredential();\nVoiceLiveClient client = new VoiceLiveClient(endpoint, credential);\n```\n\n**Required Role**: `Cognitive Services User` (assign in Azure Portal → Access control)\n\n### API Key\n\n```csharp\nUri endpoint = new Uri(\"https:\u002F\u002Fyour-resource.cognitiveservices.azure.com\");\nAzureKeyCredential credential = new AzureKeyCredential(\"your-api-key\");\nVoiceLiveClient client = new VoiceLiveClient(endpoint, credential);\n```\n\n## Client Hierarchy\n\n```\nVoiceLiveClient\n└── VoiceLiveSession (WebSocket connection)\n    ├── ConfigureSessionAsync()\n    ├── GetUpdatesAsync() → SessionUpdate events\n    ├── AddItemAsync() → UserMessageItem, FunctionCallOutputItem\n    ├── SendAudioAsync()\n    └── StartResponseAsync()\n```\n\n## Core Workflow\n\n### 1. Start Session and Configure\n\n```csharp\nusing 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\u002F\u002F Start session\nusing VoiceLiveSession session = await client.StartSessionAsync(model);\n\n\u002F\u002F 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\u002F\u002F 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```\n\n### 2. Process Events\n\n```csharp\nawait foreach (SessionUpdate serverEvent in session.GetUpdatesAsync())\n{\n    switch (serverEvent)\n    {\n        case SessionUpdateResponseAudioDelta audioDelta:\n            byte[] audioData = audioDelta.Delta.ToArray();\n            \u002F\u002F 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            \u002F\u002F 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```\n\n### 3. Send User Message\n\n```csharp\nawait session.AddItemAsync(new UserMessageItem(\"Hello, can you help me?\"));\nawait session.StartResponseAsync();\n```\n\n### 4. Function Calling\n\n```csharp\n\u002F\u002F 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\u002F\u002F Add to session options\nsessionOptions.Tools.Add(weatherFunction);\n\n\u002F\u002F 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\u003CDictionary\u003Cstring, string>>(functionCall.Arguments);\n        string location = parameters?[\"location\"] ?? \"\";\n        \n        \u002F\u002F Call external service\n        string weatherInfo = $\"The weather in {location} is sunny, 75°F.\";\n        \n        \u002F\u002F Send response\n        await session.AddItemAsync(new FunctionCallOutputItem(functionCall.CallId, weatherInfo));\n        await session.StartResponseAsync();\n    }\n}\n```\n\n## Voice Options\n\n| Voice Type | Class | Example |\n|------------|-------|---------|\n| Azure Standard | `AzureStandardVoice` | `\"en-US-AvaNeural\"` |\n| Azure HD | `AzureStandardVoice` | `\"en-US-Ava:DragonHDLatestNeural\"` |\n| Azure Custom | `AzureCustomVoice` | Custom voice with endpoint ID |\n\n## Supported Models\n\n| Model | Description |\n|-------|-------------|\n| `gpt-4o-realtime-preview` | GPT-4o with real-time audio |\n| `gpt-4o-mini-realtime-preview` | Lightweight, fast interactions |\n| `phi4-mm-realtime` | Cost-effective multimodal |\n\n## Key Types Reference\n\n| Type | Purpose |\n|------|---------|\n| `VoiceLiveClient` | Main client for creating sessions |\n| `VoiceLiveSession` | Active WebSocket session |\n| `VoiceLiveSessionOptions` | Session configuration |\n| `AzureStandardVoice` | Standard Azure voice provider |\n| `AzureSemanticVadTurnDetection` | Voice activity detection |\n| `VoiceLiveFunctionDefinition` | Function tool definition |\n| `UserMessageItem` | User text message |\n| `FunctionCallOutputItem` | Function call response |\n| `SessionUpdateResponseAudioDelta` | Audio chunk event |\n| `SessionUpdateResponseTextDelta` | Text chunk event |\n\n## Best Practices\n\n1. **Always set both modalities** — Include `Text` and `Audio` for voice assistants\n2. **Use `AzureSemanticVadTurnDetection`** — Provides natural conversation flow\n3. **Configure appropriate silence duration** — 500ms typical to avoid premature cutoffs\n4. **Use `using` statement** — Ensures proper session disposal\n5. **Handle all event types** — Check for errors, audio, text, and function calls\n6. **Use DefaultAzureCredential** — Never hardcode API keys\n\n## Error Handling\n\n```csharp\nif (serverEvent is SessionUpdateError error)\n{\n    if (error.Error.Message.Contains(\"Cancellation failed: no active response\"))\n    {\n        \u002F\u002F Benign error, can ignore\n    }\n    else\n    {\n        Console.WriteLine($\"Error: {error.Error.Message}\");\n    }\n}\n```\n\n## Audio Configuration\n\n- **Input Format**: `InputAudioFormat.Pcm16` (16-bit PCM)\n- **Output Format**: `OutputAudioFormat.Pcm16`\n- **Sample Rate**: 24kHz recommended\n- **Channels**: Mono\n\n## Related SDKs\n\n| SDK | Purpose | Install |\n|-----|---------|---------|\n| `Azure.AI.VoiceLive` | Real-time voice (this SDK) | `dotnet add package Azure.AI.VoiceLive` |\n| `Microsoft.CognitiveServices.Speech` | Speech-to-text, text-to-speech | `dotnet add package Microsoft.CognitiveServices.Speech` |\n| `NAudio` | Audio capture\u002Fplayback | `dotnet add package NAudio` |\n\n## Reference Links\n\n| Resource | URL |\n|----------|-----|\n| NuGet Package | https:\u002F\u002Fwww.nuget.org\u002Fpackages\u002FAzure.AI.VoiceLive |\n| API Reference | https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fapi\u002Fazure.ai.voicelive |\n| GitHub Source | https:\u002F\u002Fgithub.com\u002FAzure\u002Fazure-sdk-for-net\u002Ftree\u002Fmain\u002Fsdk\u002Fai\u002FAzure.AI.VoiceLive |\n| Quickstart | https:\u002F\u002Flearn.microsoft.com\u002Fazure\u002Fai-services\u002Fspeech-service\u002Fvoice-live-quickstart |\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,77,1411,"2026-05-16 13:05:37",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"编程开发","coding","mdi-code-braces","代码生成、调试、审查，提升开发效率",2,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":33,"createdAt":26},"DevOps","devops","mdi-cog-outline","CI\u002FCD、容器化、部署运维",3,162,[35],{"id":36,"skillId":4,"version":37,"fileName":38,"fileSize":39,"filePath":40,"fileHash":41,"manifest":42,"createdAt":19},"877f046a-275a-4ae7-88e9-0086a3bca51f","1.0.0","azure-ai-voicelive-dotnet.zip",3277,"uploads\u002Fskills\u002F2c26ca58-3cf8-497e-b103-4022cac78cfe\u002Fazure-ai-voicelive-dotnet.zip","910c1b9a699345ef889bf407337cd1d05f8b69799806039b511bd129fe303c13","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":8703}]",{"code":44,"message":45,"data":46},200,"success",{"items":47,"stats":48,"page":51},[],{"averageRating":49,"totalRatings":49,"ratingCounts":50},0,[49,49,49,49,49],{"limit":52,"offset":49,"hasMore":53,"nextOffset":52,"ratedOnly":16},15,false]