azure-ai-voicelive-py 是什么?
这是 azure-ai-voicelive 的异步 Python Skill,通过 WebSocket 连接配置语音会话,连续发送/接收音频和转录事件,处理自动或手动轮次、中断及函数调用。它需要接入采音/播放设备,并把工具执行留在应用控制面。
中文说明由本站依据来源整理;英文原文保留在页面下方。
怎么接入你的 Agent?
- 定位完整 Skill 目录
打开本项目来源,核对
SKILL.md及其引用的脚本和资料。 - 交给你正在用的 Agent
在下面选择客户端,展开并复制安装指令,让 Agent 读取来源后选择安装方式。
- 确认识别,再做具体任务
让 Agent 回报安装目录和识别到的名称
azure-ai-voicelive-py,然后按本页使用示例提供材料。
展开并复制给 Codex 的安装指令
安装并检查 azure-ai-voicelive-py
请在 Codex 的当前工作环境中安装并检查 azure-ai-voicelive-py 这个 Skill。
项目身份:microsoft/skills / azure-ai-voicelive-py
来源:https://github.com/microsoft/skills/blob/f03ec5392f7a0f3aca12af47477e92f1edf7b44c/.github/plugins/azure-sdk-python/skills/azure-ai-voicelive-py/SKILL.md
已定位的源文件:.github/plugins/azure-sdk-python/skills/azure-ai-voicelive-py/SKILL.md
1. 先阅读真实 SKILL.md 和它引用的必要文件,确认触发条件、安装方式、依赖与权限;尊重源文件要求的审批步骤。
2. 按当前客户端支持的方式安装完整 Skill 目录,保留已有配置,不只复制一段提示词。涉及缺失凭证、目标目录或权限时先列出缺项并向我确认。
3. 安装后回读实际目录、Skill 名称和识别结果,说明哪些步骤已完成,哪些只是文档检查,不得把安装成功当作任务已经实测。
4. 如来源提供了可安全验证的示例,在我提供所需输入后做一个最小任务;创建、修改、删除、部署或发送内容前,按源文件和我的授权执行。展开并复制给 Claude Code 的安装指令
安装并检查 azure-ai-voicelive-py
请在 Claude Code 的当前工作环境中安装并检查 azure-ai-voicelive-py 这个 Skill。
项目身份:microsoft/skills / azure-ai-voicelive-py
来源:https://github.com/microsoft/skills/blob/f03ec5392f7a0f3aca12af47477e92f1edf7b44c/.github/plugins/azure-sdk-python/skills/azure-ai-voicelive-py/SKILL.md
已定位的源文件:.github/plugins/azure-sdk-python/skills/azure-ai-voicelive-py/SKILL.md
1. 先阅读真实 SKILL.md 和它引用的必要文件,确认触发条件、安装方式、依赖与权限;尊重源文件要求的审批步骤。
2. 按当前客户端支持的方式安装完整 Skill 目录,保留已有配置,不只复制一段提示词。涉及缺失凭证、目标目录或权限时先列出缺项并向我确认。
3. 安装后回读实际目录、Skill 名称和识别结果,说明哪些步骤已完成,哪些只是文档检查,不得把安装成功当作任务已经实测。
4. 如来源提供了可安全验证的示例,在我提供所需输入后做一个最小任务;创建、修改、删除、部署或发送内容前,按源文件和我的授权执行。展开并复制给 Cursor 的安装指令
安装并检查 azure-ai-voicelive-py
请在 Cursor Agent 的当前工作环境中安装并检查 azure-ai-voicelive-py 这个 Skill。
项目身份:microsoft/skills / azure-ai-voicelive-py
来源:https://github.com/microsoft/skills/blob/f03ec5392f7a0f3aca12af47477e92f1edf7b44c/.github/plugins/azure-sdk-python/skills/azure-ai-voicelive-py/SKILL.md
已定位的源文件:.github/plugins/azure-sdk-python/skills/azure-ai-voicelive-py/SKILL.md
1. 先阅读真实 SKILL.md 和它引用的必要文件,确认触发条件、安装方式、依赖与权限;尊重源文件要求的审批步骤。
2. 按当前客户端支持的方式安装完整 Skill 目录,保留已有配置,不只复制一段提示词。涉及缺失凭证、目标目录或权限时先列出缺项并向我确认。
3. 安装后回读实际目录、Skill 名称和识别结果,说明哪些步骤已完成,哪些只是文档检查,不得把安装成功当作任务已经实测。
4. 如来源提供了可安全验证的示例,在我提供所需输入后做一个最小任务;创建、修改、删除、部署或发送内容前,按源文件和我的授权执行。展开并复制给 当前 Agent 的安装指令
安装并检查 azure-ai-voicelive-py
请在 当前 Agent 的当前工作环境中安装并检查 azure-ai-voicelive-py 这个 Skill。
项目身份:microsoft/skills / azure-ai-voicelive-py
来源:https://github.com/microsoft/skills/blob/f03ec5392f7a0f3aca12af47477e92f1edf7b44c/.github/plugins/azure-sdk-python/skills/azure-ai-voicelive-py/SKILL.md
已定位的源文件:.github/plugins/azure-sdk-python/skills/azure-ai-voicelive-py/SKILL.md
1. 先阅读真实 SKILL.md 和它引用的必要文件,确认触发条件、安装方式、依赖与权限;尊重源文件要求的审批步骤。
2. 按当前客户端支持的方式安装完整 Skill 目录,保留已有配置,不只复制一段提示词。涉及缺失凭证、目标目录或权限时先列出缺项并向我确认。
3. 安装后回读实际目录、Skill 名称和识别结果,说明哪些步骤已完成,哪些只是文档检查,不得把安装成功当作任务已经实测。
4. 如来源提供了可安全验证的示例,在我提供所需输入后做一个最小任务;创建、修改、删除、部署或发送内容前,按源文件和我的授权执行。装好以后,具体怎么用?
准备哪些材料
- 安装 azure-ai-voicelive、aiohttp、azure-identity;仅使用 .aio client 和异步身份。
- 配置区域/资源 endpoint、实时模型与所需角色,核对模型是否支持目标区域。
- 语音PCM输入要和配置一致;默认样例是PCM16、24kHz、单声道。准备麦克风采集和播放实现。
实际使用顺序
- 以 async with 管理 DefaultAzureCredential 和 connect,成功后用 session.update 配置指令、模态、voice 与VAD。
- 异步消费 conn 事件,区分输入转录、输出文字/音频、response.done 和 error。
- 自动VAD模式由声音活动结束触发;手动模式显式 append→commit→response.create。中断时取消当前响应并清空未播缓冲。
- function call 先按允许列表和参数 schema 校验,再执行工具,把 JSON 输出写回 conversation 并请求续答;避免把 API 凭据或原始音频记日志。
从一个具体任务开始
本站根据源文件编写的使用示例,未在本站实际运行。示例中的文件由你提供。
复制一个具体任务
请按 azure-ai-voicelive-py 给出一个不接麦克风的会话循环草案:建立异步连接,配置文本和音频模式,只打印转录完成与response.done状态,并正确关闭凭据和连接。先不连接服务。得到异步会话结构示例;没有生成真实语音或建立网络连接。
使用条件与边界
- 源文可选 AzurePersonalVoice 不是克隆声线开关;需单独确认授权、资格、speaker profile 与服务支持。
- MCP、函数调用和头像仅为可扩展能力;当前源文的详细事件实现主要演示函数调用,不可宣称已配置远端 MCP。
- Audio格式与端点在各语言 SDK 中存在差别,不能直接复制 .NET 或 Java 的环境变量与模型名。
常见问题
服务不返回 response.done 怎么排查?
确认输入轮次已完成:VAD是否检测到停顿,手动模式是否 commit 并显式请求 response;同时消费错误事件。
为什么代码开麦克风仍然听不到声音?
源文把 read_audio_from_microphone 和 play_audio 留作调用方实现。还需授予设备权限、正确重采样并播放返回PCM数据。
来源原文与资料状态
- 源文件
- 已保存 SKILL.md,抓取于 2026-11-16T12:36:35.145Z
- 中文使用说明
- 已针对下方源文件版本整理用途、用法和常见问题
- 安装与任务测试
- 本站未执行安装或任务测试
- 来源复核
- 本页中文用法已对照保存版本的完整 SKILL.md 阅读整理
展开 SKILL.md 原文、章节与历史收录资料
.github/plugins/azure-sdk-python/skills/azure-ai-voicelive-py/SKILL.md · 抓取时间 2026-11-16T12:36:35.145Z
以下保留源文件的 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 Azure AI, including voice assistants, voice-enabled chatbots, real-time speech-to-speech translation, voice-driven avatars, or any WebSocket-based audio streaming with AI models. Supports Server VAD (Voice Activity Detection), turn-based conversation, function calling, MCP tools, avatar integration, and transcription.
查看源文件章节 / Source sections
- 原文:Azure AI Voice Live SDK
- 安装 / Installation
- 原文:Environment Variables
- 原文:Authentication & Lifecycle
- 原文:Legacy: API Key (existing keyed deployments)
- 快速开始 / Quick Start
- 原文:Core Architecture
- 原文:Connection Resources
- 原文:Session Configuration
- 原文:Audio Streaming
- 原文:Send Audio (Base64 PCM16)
- 原文:Receive Audio
- 原文:Event Handling
- 原文:Common Patterns
- 原文:Manual Turn Mode (No VAD)
- 原文:Interrupt Handling
- 原文:Conversation History
- 原文:Voice Options
- 原文:Audio Formats
- 原文:Turn Detection Options
- 原文:Error Handling
- 原文:Best Practices
- 原文:References
原文:Azure AI Voice Live SDK
Build real-time voice AI applications with bidirectional WebSocket communication.
安装 / Installation
```bash pip install azure-ai-voicelive aiohttp azure-identity ```
原文:Environment Variables
```bash AZURE_COGNITIVE_SERVICES_ENDPOINT=https://<region>.api.cognitive.microsoft.com # Required for all auth methods AZURE_TOKEN_CREDENTIALS=prod # Required only if DefaultAzureCredential is used in production AZURE_COGNITIVE_SERVICES_KEY=<api-key> # Only required for the legacy API-key auth path below ```
原文:Authentication & Lifecycle
> **🔑 Two rules apply to every code sample below:** > > 1. **Prefer `DefaultAzureCredential`.** It works locally (Azure CLI / VS Code / Developer CLI) and in Azure (managed identity, workload identity) with no code change. Avoid connection strings, account/API keys — they bypass Entra audit and rotation. > - Local dev: `DefaultAzureCredential` works as-is. > - Production: set `AZURE_TOKEN_CREDENTIALS=prod` (or `AZURE_TOKEN_CREDENTIALS=<specific_credential>`) to constrain the credential chain to production-safe credentials. > 2. **Wrap every client in a context manager** so HTTP transports, sockets, and token caches are released deterministically: > - Sync: `with <Client>(...) as client:` > - Async: `async with <Client>(...) as client:` **and** `async with DefaultAzureCredential() as credential:` (from `azure.identity.aio`) > > Snippets may abbreviate this setup, but production code should always follow both rules. ```python import os from azure.ai.voicelive.aio import connect from azure.identity.aio import DefaultAzureCredential, ManagedIdentityCredential # Local dev: DefaultAzureCredential. Production: set AZURE_TOKEN_CREDENTIALS=prod or AZURE_TOKEN_CREDENTIALS=<specific_credential> # Or use a specific credential directly in production: # See https://learn.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#credential-classes # credential = ManagedIdentityCredential() async with DefaultAzureCredential(require_envvar=True) as credential: async with connect( endpoint=os.environ["AZURE_COGNITIVE_SERVICES_ENDPOINT"], credential=credential, model="gpt-4o-realtime-preview", credential_scopes=["https://cognitiveservices.azure.com/.default"] ) as conn: ... ```
原文:Legacy: API Key (existing keyed deployments)
New code should use `DefaultAzureCredential` above. Use `AzureKeyCredential` only if you have an existing keyed deployment that hasn't been migrated to Entra ID yet — for example, regulated environments still completing their Entra rollout. ```python import os from azure.core.credentials import AzureKeyCredential from azure.ai.voicelive.aio import connect async with connect( endpoint=os.environ["AZURE_COGNITIVE_SERVICES_ENDPOINT"], credential=AzureKeyCredential(os.environ["AZURE_COGNITIVE_SERVICES_KEY"]), model="gpt-4o-realtime-preview", ) as conn: ... ```
快速开始 / Quick Start
```python import asyncio import os from azure.ai.voicelive.aio import connect from azure.identity.aio import DefaultAzureCredential async def main(): async with connect( endpoint=os.environ["AZURE_COGNITIVE_SERVICES_ENDPOINT"], credential=DefaultAzureCredential(), model="gpt-4o-realtime-preview", credential_scopes=["https://cognitiveservices.azure.com/.default"] ) as conn: # Update session with instructions await conn.session.update(session={ "instructions": "You are a helpful assistant.", "modalities": ["text", "audio"], "voice": "alloy" }) # Listen for events async for event in conn: print(f"Event: {event.type}") if event.type == "response.audio_transcript.done": print(f"Transcript: {event.transcript}") elif event.type == "response.done": break asyncio.run(main()) ```
文件 SHA256:8a765d22c122b71f8726aded787a45e248ed3823fdf373cc041d3adc2a5814f5
仓库许可证记录:MIT;skill-declaration-captured-not-interpreted,查看来源。
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 Azure AI, including voice assistants, voice-enabled chatbots, real-time speech-to-speech translation, voice-driven avatars, or any WebSocket-based audio streaming with AI models. Supports Server VAD (Voice Activity Detection), turn-based conversation, function calling, MCP tools, avatar integration, and transcription.
历史收录数据
| 来源仓库 | microsoft/skills |
|---|---|
| Skill源路径 | .github/plugins/azure-sdk-python/skills/azure-ai-voicelive-py/SKILL.md |
安装前请让使用的Agent先读取这个SKILL.md及其所在目录,确认依赖和所需权限。此页不生成未经来源验证的安装命令。
