node.js - Cutoff appears in output mp3 from request.pipe function, while making request to AVS api -


i have developed nodejs-client replaces javaclient provided avs (alexa voice service) sample code.

the code used makes post request, , pipes output mp3 file. many times output mp3 not complete , broken end, , beginning. eg. desired mp3 file duration 9sec, output file 8sec long or 6sec long, or complete 9sec long.

its random behaviour.

code used make api request , redirect o/p file below. let me know whats wrong here, new request piping.

var options = { url: 'https://access-alexa-na.amazon.com/v1/avs/speechrecognizer/recognize', headers:{   'content-type':'multipart/form-data',   'transfer-encoding':'chunked' }, formdata: formdata };  var destination = fs.createwritestream(path.join(__dirname,outputfile));  //request.debug = 1; request.post(options, function optionalcallback(err, httpresponse, body)     {   //console.log(httpresponse);   if(body.length < 100){     console.log(body);   }   console.log("\n\r----processing done ("+outputfile+")----");   if(loadingint!=null)clearinterval(loadingint);   process.exit();   if (err) {     return console.error('upload failed:', err);   }   //console.log('upload successful!  server responded with:', body); }).auth(null, null, true, token) .pipe(destination); 

i had raised avs guys, told issue code, , ot api.

the problem process.exit() call. not sure why in there @ all. exit call exiting process before piping completed.


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -