question

Daniel avatar image
Daniel asked

Simple Speechrecognizer example to run with CURL

Hello all, I am failing to post a simple request to the recognize request (I'm using the Postman Chrome Extension to try things out). Here are my header and body: HEADER POST /v1/avs/speechrecognizer/recognize HTTP/1.1 Host: access-alexa-na.amazon.com Content-Type: multipart/form-data; boundary=86371ffc080fbb6fc614e8e36d0b8a4d Authorization: Bearer Atza|IQEB... 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": "1", "offsetInMilliseconds": "0", "playerActivity": "IDLE" } } ] }, "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 5249 4646 b80a 0200 5741 5645 666d 7420 1000 0000 0100 0100 803e 0000 007d 0000 0200 1000 4c49 5354 1a00 0000 494e ... --86371ffc080fbb6fc614e8e36d0b8a4d-- RESPONSE { "error": { "code": "com.amazon.alexahttpproxy.exceptions.InternalServerError", "message": "Request could not be executed due to an internal service error." } } As the response is rather generic about the error occured I am assuming that the wav file might be the issue. The link to the wav file: http://zank.s3.amazonaws.com/alexa-what-time-is-it-16bit-16hz-mono-pcm.wav It simply says "alexa, what time is it?" 16bit, 16000Hz, mono, pcm. Can anyone help?
alexa voice service
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

E. McDonald avatar image
E. McDonald answered
I believe if you change the "streamId": "1" to "streamId": "" it will work.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Eric@Amazon avatar image
Eric@Amazon answered
E. McDonald is correct - when there is no stream playing, the streamId should be an empty string. Has that fixed your problem? -Eric
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Daniel avatar image
Daniel answered
Thank you, that does make sense but didn't seem to be obvious to me. After setting "streamId" to an empty string, I get "204 - No Content". Why don't I get a response?
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

E. McDonald avatar image
E. McDonald answered
I actually have a complete curl example that might help, see https://gist.github.com/carsonmcdonald/4151ba9b5d5ba8e983b8 Just change the AT value to a valid auth token and the test.wav to your wav filename.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Daniel avatar image
Daniel answered
E. McDonald, this is awesome, exactly what I was looking for. I works, with my wav file as well, thank you!
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.