# Azure Pronunciation Assessment 资源/key 就绪诊断与 smoke test
## Azure Pronunciation Assessment 诊断流程样例
### 工具入口
```bash
python tools/azure_speech_pronunciation_diag.py \
--audio samples/pronunciation_smoke.wav \
--reference-text "Good morning, welcome to the lesson."
```
### 输入来源
| 输入 | 来源 | 用途 |
| --- | --- | --- |
| `AZURE_SPEECH_KEY` | 环境变量或 `az cognitiveservices account keys list` | REST 鉴权 |
| `AZURE_SPEECH_REGION` | 环境变量或 Speech resource location | 拼接 endpoint |
| sample WAV | 本地样例音频 | short-audio smoke test |
| reference text | CLI 参数 | Pronunciation Assessment header |
| Azure account | `az account show` | 判断登录态、tenant、subscription |
### 核心检查步骤
1. 检查 `az` 是否存在;不存在则提示安装 Azure CLI。
2. 检查 `az account show`;失败则提示 `az login`。
3. 检查当前账号、tenant、subscription;如果出现 `not in Microsoft Services tenant`,直接判定为租户/账号权限阻塞。
4. 优先使用 `AZURE_SPEECH_KEY` 和 `AZURE_SPEECH_REGION`;缺失时尝试从指定 resource group/resource name 读取 Speech key。
5. 发送 REST short-audio 请求,带 `Pronunciation-Assessment` header。
6. 输出结构化结论:`READY`、`BLOCKED_BY_TENANT`、`MISSING_KEY_REGION`、`RESOURCE_NOT_FOUND`、`SMOKE_FAILED`。
### 成功信号
```text
READY
account:
[email protected]
subscription: xxx
region: eastus
smoke: HTTP 200
pronunciation_score: 86.0
```
### 失败信号
```text
BLOCKED_BY_TENANT
reason:
[email protected] is not in Microsoft Services tenant
next_action: switch to an account with Azure subscription access, invite the account as external user, or manually provide AZURE_SPEECH_KEY/AZURE_SPEECH_REGION and rerun smoke
```
### 建议落地
把这个流程变成 product-bu 的工作区 skill。以后用户说“Azure Pronunciation Assessment 还没通 / key 在哪 / 测一下接口”时,agent 先跑诊断入口,只有诊断明确需要交互登录或租户授权时才把动作交还给用户。