我有这个node.js代码将wav
文件上传到语音到文本。但它不起作用。
我回来了
{"RecognitionStatus":"InitialSilenceTimeout","Offset":58100000,"Duration":0}
码
var data = fse.readFileSync("assets/batman.wav");
data = data.toString();
var options = {
host : 'speech.platform.bing.com',
//port : 443,
path : '/speech/recognition/dictation/cognitiveservices/v1?language=en-US&format=simple',
method : 'POST',
headers : {
'Ocp-Apim-Subscription-Key' : 'my key',
'Content-type' : 'audio/wav; codec=audio/pcm; samplerate=16000'
}
};
var req = https.request(options, function(res) {
var buffer = "";
res.on('data', function(chunk) {
buffer += chunk;
});
res.on('end', function() {
var str = buffer.toString();
console.log("A", buffer);
//var json = JSON.parse(buffer.toString());
//console.log(json);
});
});
req.on('error', function(e) {
console.log('problem with request:', e.message);
});
// add data
req.write(data);
req.end();
任何人都知道什么是错的?
由于