I'm Downloading the file using nodejs to local and sending it to the google cloud speech api. But I keep on getting this below error while sending it.
error { Error: No audio content.
at A:\myprojects\twilio-bot\voicecall-bot\node_modules\grpc\src\node\src\cli
ent.js:434:17
code: 3,
metadata: Metadata { _internal_repr: {} },
note: 'Exception occurred in retry method that was not classified as
transient}
Here is my Code below, Can somebody help me, I don't know what I'm doing wrong.
PS: The speech api code working fine with already existing local file.
var fs = require('fs');
var request = require("request");
var Audioinput = "./currentaudio.wav";
var Currentdataurl = "https Url of the audio.wav";
//I didn't use this because I'm downloading file over https.
request.get(Currentdataurl)
.on('error', function(err) {
console.log(err)
}).pipe(fs.createWriteStream(Audioinput));
speech.recognize(Audioinput, {
encoding: 'LINEAR16',
sampleRateHertz: 8000,
languageCode: "en-IN"
}, function(err, transcript) {
if(err){
console.log("error", err);
} else {
console.log("data1",transcript);
}});
via Devan
No comments:
Post a Comment