question

harward-o2 avatar image
harward-o2 asked

how to get the json reponse by sending a audio request

1.what's the xxxxxxxxxx and ........ means ? what can I fill in, or where can I get thoese informations? 2.when I remove the content in "messageHeader" block, the server responses 204 code to me(if I send the file repeatly, I can get 200 code sometimes, but 204 code more often ), when I fill in something randomly, it responses 500 code to me. 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" } thank you
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.

Eric@Amazon avatar image
Eric@Amazon answered
The streamId is supplied by AVS. You do not need to generate any special values for it. Each stream returned by audio player events contains a stream id (see: https://developer.amazon.com/public/solutions/alexa/alexa-voice-service/rest/audioplayer-events-response#stream-json-object). If you don't have an active stream, send an empty string. offsetInMilliseconds and playerActivity are values that you supply (see: https://developer.amazon.com/public/solutions/alexa/alexa-voice-service/rest/audioplayer-events-requests#playback-state-json-object). If you have not started playback of the stream, offsetInMilliseconds should be 0 and playerActivity should be IDLE. When you get a play directive, offsetInMilliseconds becomes how far into the stream you are, and playerActivity should be PLAYING. If you receive a stop directive, playerActivity should be PAUSED. The ... represent additional deviceContext objects. Currently, there is only playbackState, but the API can support others. Finally, the message header block should always be there. You'll never get a response without 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.

harward-o2 avatar image
harward-o2 answered
i have followed your suggestion to fill in the params,this is my request body.(*********************** is outPutStream of PCM format audio file) i send this request with the same audio file many times ,but it only response 200code to me the first time, other time to response 204 code to me, --kevenACC111111 Content-Disposition: form-data; name="request" Content-Type: application/json; charset=UTF-8 { "messageHeader": { "deviceContext": [ { "name": "playbackState", "namespace": "AudioPlayer", "payload": { "streamId":"", "offsetInMilliseconds":0, "playerActivity":"IDLE" } } ] }, "messageBody": { "profile": "alexa-close-talk", "locale": "en-us", "format": "audio/L16; rate=16000; channels=1" } } --kevenACC111111 Content-Disposition: form-data; name="audio" Content-Type: audio/L16; rate=16000; channels=1 ************************************ --kevenACC111111--
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
Can you send me the request id? It should be returned as part of the 200/204 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.

harward-o2 avatar image
harward-o2 answered
this is return 200 code {'x-amzn-RequestId': '2e316286-dacc-11e5-8c75-cf3c39d0dba4', 'Content-Encoding': 'gzip', 'Transfer-Encoding': 'chunked', 'Vary': 'Accept-Encoding,User-Agent', 'Server': 'Server', 'Connection': 'keep-alive', 'Date': 'Wed, 24 Feb 2016 07:57:04 GMT', 'Content-Type': 'multipart/related; boundary=80deae74-ee58-4993-a5b6-96eddd99213c; start=metadata.1456300624138; type="application/json"'} this is return 204 code {'x-amzn-RequestId': '826ca2c2-dc2b-11e5-af36-7fd906fb3168', 'Content-Length': '0', 'Vary': 'Accept-Encoding,User-Agent', 'Server': 'Server', 'Connection': 'keep-alive', 'Date': 'Fri, 26 Feb 2016 01:51:53 GMT', 'Content-Type': 'application/json', 'x-amzn-ErrorType': 'NoContentException: https://developer.amazon.com/edw/home.html'} {'x-amzn-RequestId': '2147189d-dc2b-11e5-9329-aff0161a9d42', 'Content-Length': '0', 'Vary': 'Accept-Encoding,User-Agent', 'Server': 'Server', 'Connection': 'keep-alive', 'Date': 'Fri, 26 Feb 2016 01:49:11 GMT', 'Content-Type': 'application/json', 'x-amzn-ErrorType': 'NoContentException: https://developer.amazon.com/edw/home.html'}
10 |5000

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

elstryan@Amazon avatar image
elstryan@Amazon answered
A 204 response will occur when there is no recognizable speech to AVS, either because the audio is not formatted correctly or there or too much noise for the audio to be processed. Please ensure that the audio is recorded and sent as raw LPCM. Additionally you should ensure that you're recording follows the other specifications: 16khz, 16bit, 1 channel Also if you have verified that the audio is in the correct format it would also be helpful if you try playing the audio bytes before streaming them and listen to the output to ensure that your voice can be heard in the recording.
10 |5000

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