Audio
Authentication
Pronunciation Assessment
接口功能:语音发音评估,支持准确性、流利度、完整性等多维度评估
Method & Path
-
POST {domain}/bp/ai/audio/pronunciation
-
POST {domain}/bp/server/user/{user_id}/ai/audio/pronunciation
Request
说明:
- request body 是 chunk 格式,需要分段发送
- request body 编码为 Transfer-Encoding,但是不能在 header 添加 Transfer-Encoding
- 第一个 chunk 为 pronunciation 的参数
- 后续 chunk 为 audio stream 内容
- audio stream,需要使用 base64 编码,并且不能添加
data:audio/mp3;base64,
前缀 - audio stream 除开最后一个 chunk,其它 chunk base64 编码时不能填充
- 目前只支持 pcm,16hz,1 声道,16bit 音频格式
第一个 chunk 的参数:
Parameters | Type | Required | Desc |
---|---|---|---|
strategy | string | true | 评估策略,目前支持 azure_pronunciation |
data | object | true | 评估配置参数 |
data 对象参数:
Parameters | Type | Required | Default | Desc |
---|---|---|---|---|
language | string | false | en-US | 语言,默认 en-US |
reference_text | string | true | - | 用于评估的标准参考文本 |
grading_system | string | false | HundredMark | 分数系统:FivePoint(0-5) 或 HundredMark(0-100) |
granularity | string | false | Phoneme | 评估粒度:Phoneme、Word 或 FullText |
enable_miscue | boolean | false | false | 启用误读检测 (Omission/Insertion) |
enable_prosody_assessment | boolean | false | false | 启用韵律评估 (重音、语调、语速、节奏) |
example:
POST /bp/ai/audio/pronunciation HTTP/1.1
Content-Type: text/plain
B7\r\n{"strategy":"azure_pronunciation","data":{"reference_text":"Hello world","grading_system":"HundredMark","granularity":"Phoneme","enable_miscue":true,"enable_prosody_assessment":true}}\r\nx\r\{x_byte_audio}\r\n0\r\n\r\n
Response
json
{
"text": "Hello world",
"raw_data": {
"Duration": 235600000,
"Id": "5246cbcca9c94da6b88fe7e3800483ec",
"NBest": [
{
"Confidence": 0.9827747,
"PronunciationAssessment": {
"AccuracyScore": 88,
"CompletenessScore": 92,
"FluencyScore": 95,
"PronScore": 88.1,
"ProsodyScore": 82.7
}
}
]
},
"unit_price": {
"input_per_price": 0.0277,
"output_per_price": 0,
"input_token": 415,
"output_token": 0
},
"strategy": "azure_pronunciation"
}
响应字段说明:
Field | Type | Desc |
---|---|---|
text | string | 识别到的音频文本 |
raw_data | object | Azure 语音评估服务原始返回数据 |
unit_price | object | 计费信息,包含输入输出单价和 token 消耗 |
strategy | string | 使用的评估策略 |
PronunciationAssessment 评分说明:
Score | Desc |
---|---|
AccuracyScore | 准确性评分,指示语音发音与参考文本的匹配程度 |
CompletenessScore | 完整性评分,指示说出了参考文本的多少内容 |
FluencyScore | 流利度评分,指示语音的自然程度 |
PronScore | 综合发音评分 |
ProsodyScore | 韵律评分,评估重音、语调、语速和节奏(需启用韵律评估) |
Error
参数错误:
json
{
"error": {
"error_type": "invalid_parameter",
"message": "invalid_parameter: reference_text is required"
}
}
请求第三方失败:
json
{
"error": {
"error_type": "backend unavailable",
"message": "XXX"
}
}
附录
客户端传输数据格式
支持的音频格式
- PCM 16kHz 单声道 16bit
- 建议录音时长:1-60 秒
- 最大文件大小:10MB