我想使用亚马逊的 Alexa 语音服务 (AVS),但是当我使用识别语音请求时,我得到的只是“{message: null}”。身份验证有效,请求似乎是正确的,因为当身份验证失败或请求格式错误时,我从 API 收到了错误消息。
我有一个 wav 音频文件,16000 Hz,1 个通道,并使用 PHP 的 base64_encode() 对 wav 文件的内容进行编码。
对于音频文件,AVS 文档只说Type: Binary Data. Represents the data for the audio.
这是我发送的请求:
标头
POST /v1/avs/speechrecognizer/recognize HTTP/1.1
Host: access-alexa-na.amazon.com
Content-Type: multipart/form-data; boundary=86371ffc080fbb6fc614e8e36d0b8a4d
Authorization: Bearer Atza|IQEBL... (valid token)
Transfer-Encoding: chunked
Cache-Control: no-cache
身体
--86371ffc080fbb6fc614e8e36d0b8a4d
Content-Disposition: form-data; name="request"
Content-Type: application/json; charset=UTF-8
{
"messageHeader": {
"deviceContext": [
{
"name":"playbackState",
"namespace":"AudioPlayer",
"payload": {
"streamId": "xxxxxxxxxxxx",
"offsetInMilliseconds": "xxxxxxxxxxxx",
"playerActivity": "xxxxxxxxxxxx"
}
}
]
},
"messageBody": {
"profile": "alexa-close-talk",
"locale": "en-us",
"format": "audio/L16; rate=16000; channels=1"
}
}
--86371ffc080fbb6fc614e8e36d0b8a4d
Content-Disposition: form-data; name="audio"
Content-Type: audio/L16; rate=16000; channels=1
SUQzAgAAAAAQS1RUMgAAFwBhb...(truncated result of base64_encode(file.wav))
--86371ffc080fbb6fc614e8e36d0b8a4d--
知道有什么问题/缺少吗?