A 事件数据包
当识别处理完成并接受识别结果时,从服务器发送到客户端。
格式
类型 JSON
A <result>
<result>中包含以下 JSON。
说明 | |||
---|---|---|---|
results | "发言区间识别结果"的数组 ※虽为数组形式,但元素数量始终为 1 个。 | ||
confidence | 置信度(0 ~ 1 的值。 0:置信度低, 1:置信度高) | ||
starttime | 发话开始时间 (音频数据开头为 0) | ||
endtime | 发话结束 时间 (音频数据开头为 0) | ||
tags | 未使用(空数组) | ||
rulename | 未使用(空字符串) | ||
text | 识别结果文本 | ||
tokens | 识别结果文本的形态素数组 | ||
written | 形态素(单词)的显示 | ||
confidence | 形态素的置信度(识别结果的似然度) | ||
starttime | 形态素的开始时间 (音频数据开头为 0) | ||
endtime | 形态素的结束时间(音频数据开头为 0) | ||
spoken | 形态素的读音 *3 | ||
utteranceid | 识别结果信息 ID *1 | ||
text | 连接所有"发言区间识别结果"的整体识别结果文本。*2 | ||
code | 表示结果的 1 个字符代码。请参阅响应代码和消息。*2 | ||
message | 表示错误内容的字符串。请参阅响应代码和消息。*2 |
*1
对于 WebSocket 语音识别协议,识别结果信息 ID 是为每个发言区间的识别结果信息分配的 ID。对于 HTTP 语音识别协议,是为 1 个会话中上传的(可能包含多个发言区间的)整个音频数据的识别结果信息分配的 ID。
*2
识别成功时
body.code == "" 且 body.message == "" 且 body.text != ""
识别失败时
body.code != "" 且 body.message != "" 且 body.text == ""
*3
日语引擎识别结果的 spoken 是平假名。 英语引擎识别结果的 spoken 不是读音(请忽略)。 中文引擎识别结果的 spoken 是拼音。
JSON 中包含的 code 和 message 列表
code | message | 说明 |
---|---|---|
"+" | "received unsupported audio format" | 接收到不支持的音频数据格式的音频数据 |
"-" | "received illegal service authorization" | 接收到非法的 APPKEY (service 认证密钥字符串) |
"!" | "failed to connect to recognizer server" | 语音识别服务器内部通信失败(连接 DSRM 或 DSRS 失败) |
">" | "failed to send audio data to recognizer server" | 语音识别服务器内部通信失败(向 DSRS 发送音频数据失败) |
"<" | "failed to receive recognition result from recognizer server" | 语音识别服务器内部通信失败(从 DSRS 接收识别结果失败) |
"#" | "received invalid recognition result from recognizer server" | 语音识别服务器内部通信失败(从 DSRS 接收到的识别结果格式不正 确) |
"$" | "timeout occurred while receiving audio data from client" | 从客户端接收音频数据时发生无通信超时 |
"%" | "received too large audio data from client" | 从客户端接收的音频数据字节数过大(WebSocket 接口不会发生) |
"o" | "recognition result is rejected because confidence is below the threshold" | 由于识别结果整体的置信度低于置信度阈值而识别失败 ※ 当从接收的整个音频数据中无法检测到任何发话,因此无法返回识别结果时,也会返回此错误。导致发言检测失败的原因可能是音频数据缺失或音频数据格式指定错误。 |
"b" | "recognition result is rejected because recognizer server is busy" | 由于语音识别服务器繁忙而识别失败 |
"x" | "recognition result is rejected because grammar files are not loaded" | 由于词典未加载而识别失败 |
"c" | "recognition result is rejected because the recognition process is cancelled" | 由于发出识别处理中断请求而识别失败 |
"t" | "recognition result is rejected because timeout occurred during recognition process" | 由于识别处理超时等原因导致识别处理中断而识别失败 |
"?" | "recognition result is rejected because fatal error occurred in recognizer server" | 由于语音识别服务器在识别过程中发生致命错误而识别失败 |
"s" | "recognition result is rejected because recognition process was not started before timeout occurred" | 由于从客户端接收的音频数据放入音频数据队列后一定时间内未开始识别处理而识别失败 |
"e" | "recognition result is rejected because recognition process was not finished before timeout occurred" | 由于从客户端接收的音频数据放入音频数据队列后一定时间内未完成识别处理而识别失败 |
"" | "" | 识别成功 |
响应示例
{
"results": [
{
"tokens": [
{
"written": "www",
"confidence": 1.0,
"starttime": 16020,
"endtime": 16916,
"spoken": "\u3068\u308a\u3077\u308b\u3060\u3076\u308b"
}
],
"confidence": 0.997,
"starttime": 15700,
"endtime": 17188,
"tags": [],
"rulename": "",
"text": "www"
}
],
"utteranceid": "20191127/ja_ja-amivoicecloud-16k-user@016ead249db00a3011a68536-1127_225504",
"text": "www",
"code": "",
"message": ""
}