question

0x427567 avatar image
0x427567 asked

Always return 204 no content in Node.js

Hello all, Here is my source code, https://gist.github.com/ShawnOY/789973aed07ada3b2ea6374c96e93ba7 I try to post a audio to AVS, but always return 204 to me, I checked audio is LPCM 16bit, with a 16khz sample rate and curl is working but Node.js is not. I try to write back the audio file and it's play fine, all format is correct, but I have no idea why AVS still return 204 to me. Could anyone help? Please~
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.

swasey@amazon avatar image
swasey@amazon answered
I see you're trying to read from a WAV file. Is that file actual wave format, or raw LPCM? If it's actual wave then it has extra header information included at the beginning of the file that will be read as gibberish by AVS and will be unable to return anything useful.
10 |5000

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

0x427567 avatar image
0x427567 answered
Hello swasey, Thanks for your reply and I found why. Because javascript is non-block, when I start send data and javascript close my connect, so AVS not recevie any audio data, I change the code and it's work. request.write(payload, function() { request.write(file, function() { request.write(endpayload, function() { request.end() }) }) }) It's oddly but it's 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.