4
我正在嘗試將bing語音用於來自Node的文本服務。流式傳輸.wav文件時出現以下錯誤。高度讚賞任何幫助。microsoft-cognitive:在NodeJS中獲取ECONNRESET錯誤的Bing語音到文本服務
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選項如下:
var post_option = {
hostname: 'speech.platform.bing.com',
path: '/recognize',
method: 'POST'
};
post_option.headers = {
'Content-Type': 'audio/wav; samplerate=16000', //'audio/wav; codec=」audio/wav」; samplerate=16000; sourcerate=8000; trustsourcerate=false',
// 'keepAlive': true,
// 'Content-Length' : waveData.length,
'Authorization': 'Bearer ' + OxfordAccessToken.access_token,
// "User-Agent": "TTSNodeJS",
'X-Search-AppId': '______',
'X-Search-ClientID': '______'
};
post_option.qs = {
'scenarios': 'ulm',
'appid': '--------', // This magic value is required
'locale': 'en-US',
'device.os': 'wp7',
'version': '3.0',
'format': 'json',
'requestid': '------', // can be anything
'instanceid': '------' // can be anything
};
的NodeJS來電SpeechToText服務
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 });
它不工作,因爲查詢字符串沒有通過URL傳遞;通過將選項中的查詢字符串附加到路徑來修復。 post_option = { 主機名: 'speech.platform.bing.com', 路徑: '/識別<<附加查詢字符串>>?', 方法: 'POST' }; – raserside