I'd like to the the Alexa voice API (https://developer.amazon.com/public/solutions/alexa/alexa-voice-service/rest/speechrecognizer-requests) with curl. The voicerecogniser API call is more complex than I'm used to using and needs an MP3 file attaching that includes the voice sample. Can anyone advise on how the following would be structured with curl? (There's more info at the given link)
POST /v1/avs/speechrecognizer/xxxxxxxxxxxx HTTP/1.1
Host: access-alexa-na.amazon.com
Authorization: Bearer xxxxxxxxxxxx
Content-Type: multipart/form-data; boundary=boundary_term
Transfer-Encoding: chunked
--boundary_term
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"
}
}
--boundary_term
Content-Disposition: form-data; name="audio"
Content-Type: audio/L16; rate=16000; channels=1
...encoded_audio_data...
--boundary_term--
I'm no bash expert but this how I was able to interact with AVS using cURL. I generate a file containing the multipart body content which includes the binary audio data and pass that along to cURL.
The audio MUST be mono channel, sampled at 16k Hz, and signed 16 bit PCM. Otherwise AVS sends nothing back.
For more information check out my Alexa Voice Service (AVS) with cURL blog post.