I would like to use Amazon's Alexa Voice Service (AVS) but when I use the Recognize Speech Request all I get back is "{message: null}". Authentication works, request seems to be correct because I've received error messages from the API when authentication failed or request was malformed.
I have a wav audio file, 16000 Hz, 1 channel, and use PHP's base64_encode() to encode the wav file's content.
For the audio file the AVS documentation only says Type: Binary Data. Represents the data for the audio.
Here's the request I'm sending:
Headers
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
Body
--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--
Any idea what's wrong/missing?
The encoding for the audio file should be Linear PCM not base 64. Hope this helps