I am trying to use bing speech for a text service from Node. The error below is when streaming a .wav file. Appreciate any help.
events.js:154
throw er; // Unhandled 'error' event
^
Error: read ECONNRESET
at exports._errnoException (util.js:890:11)
at TLSWrap.onread (net.js:550:26)
Http options:
var post_option = {
hostname: 'speech.platform.bing.com',
path: '/recognize',
method: 'POST'
};
post_option.headers = {
'Content-Type': 'audio/wav; samplerate=16000',
'Authorization': 'Bearer ' + OxfordAccessToken.access_token,
'X-Search-AppId': '______',
'X-Search-ClientID': '______'
};
post_option.qs = {
'scenarios': 'ulm',
'appid': '--------',
'locale': 'en-US',
'device.os': 'wp7',
'version': '3.0',
'format': 'json',
'requestid': '------',
'instanceid': '------'
};
NodeJS calls the SpeechToText service
res.on('end', function(){
OxfordAccessToken = eval ('(' + _data + ')');
var voiceStream = fs.createReadStream("voiceresponse.wav",{encoding: "binary"});
var https = require('https');
var post_req = https.request(getPostOptionsForSTT(OxfordAccessToken), (res) =>{
if(err){
console.log("Error during STT");
}
var sttResponse;
res.on('data', function(buffer){
sttResponse += buffer;
});
console.log("STT Results : "+sttResponse);
});
voiceStream.pipe(post_req,{ end: false });
source
share