question

bporch5053 avatar image
bporch5053 asked

500 Internal Server Error

Can anyone shed light on what is wrong with this request? I can successfully authenticate but I am receiving a 500 Internal Server error when I post a recognize request. Headers: POST /v1/avs/speechrecognizer/recognize HTTP/1.1 Accept: */* Authorization: Bearer Host: access-alexa-na.amazon.com Content-type: multipart/form-data; boundary=---------------------------boundary Transfer-Encoding: chunked Body: ---------------------------boundary Content-Disposition: form-data; name="request" Content-Type: application/json; charset=UTF-8 { "messageHeader": { "deviceContext": [ { "name": "playbackState", "namespace": "AudioPlayer" "payload": { "streamId": "", "offsetInMilliseconds": "", "playerActivity": "IDLE" } } ] }, "messageBody": { "profile": "doppler-scone", "locale": "en-us", "format": "audio/L16; rate=16000; channels=1" } } ---------------------------boundary Content-Disposition: form-data; name="audio" Content-Type: audio/L16; rate=16000; channels=1 ---------------------------boundary--
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.

vikramezhil avatar image
vikramezhil answered
Just out of curiosity what did you pass in the scope data for [b]PRODUCT_ID[/b] & [b]PRODUCT_DSN[/b] ?
10 |5000

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

invoxia avatar image
invoxia answered
"namespace": "AudioPlayer" is missing a terminating comma, isn't it ?
10 |5000

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

bporch5053 avatar image
bporch5053 answered
Thanks for the catch. I corrected that but it didn't solve the issue.
10 |5000

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

bporch5053 avatar image
bporch5053 answered
Product ID is 'AlexaLink' Product DSN is '1234' for testing purposes.
10 |5000

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

invoxia avatar image
invoxia answered
Hmm... I would say that the boundaries in the body are missing a heading double-dash: if your boundary is '---------------------------boundary' (with 27 '-') you should get '-----------------------------boundary' (with 29 '-') in the body (or possibly you meant to have a 25-dash boundary ? so you have to remove 2 dashes in the Content-Type header)
10 |5000

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

Beefalo avatar image
Beefalo answered
Per the previous comments: 1) Missing comma after "namespace":"AudioPlayer" -- sounds like you already fixed this 2) Double check your boundaries, should be: boundary= -- -- -- -- 3) The audio should be sent up as raw LPCM and NOT base64-endoded
10 |5000

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

bporch5053 avatar image
bporch5053 answered
I got this working. Turns out that the multipart format is particular about '\r\n" line terminators. Thanks!
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
Can you elaborate on how to send the Audio file as Raw LPCM instead of base64_encoded? How would you do that eg. with curl? Thanks!
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
Daniel, does this thread help? https://forums.developer.amazon.com/forums/message.jspa?messageID=19142#19142 From your other post in [i]Simple Speechrecognizer example to run with CURL[/i], it seems as though you have a PCM file to test with - just remember not to include the WAV's headers when sending the data. -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
Hi Eric, I have a PCM file but I seem to have troubles understanding how exactly I have to go from the wav file to some kind of a string to put into the request. I currently assume I have a correct PCM file (I've linked it to the [i]Simple Speechrecognizer example to run with CURL[/i] thread) but I'm missing the step getting it from the file into the request. What I've been doing so far is simply opening the wav file in a text editor, selecting all, copy and paste it into the request body (which seems to be not working especially when you mention NOT to include the wav headers). I feel stupid, but how would I do that? I know this sounds stupid, but how?
10 |5000

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