I am using the IBM Watson Speech to Text API:
var SpeechToTextV1 = require('watson-developer-cloud/speech-to-text/v1');
var fs = require('fs');
var request = require('request');
var speech_to_text = new SpeechToTextV1({
"username": "<user name>",
"password": "<password>"
});
var recognizeStream = speech_to_text.createRecognizeStream();
// request(wavfileURL).pipe(recognizeStream);
// recognizeStream.on('results', function(err, res){
// console.dir(err)
// console.dir(res)
// if (res.results){
// console.dir(res.results)
// }
//
// });
request.get(wavfileURL, function (err, res, buffer) {
var streamer = require('streamifier');
var params = {
// From file
audio: streamer.createReadStream(buffer) ,
content_type: 'audio/wav; rate=44100'
};
speech_to_text.recognize(params, function(err, res) {
debugger;
if (err)
console.log("ERR:",err);
else {
console.log("NOT ERR");
console.log(JSON.stringify(res, null, 2));
console.dir(res);
}
});
});
I call it with the following WAV file https://s3.amazonaws.com/buzzy-audio/adam.ginsburg%40gmail.com/vNixvnC4Xscu8yZ98
And I get the following error:
> ERR: { [Error: unable to transcode data stream audio/wav ->
> audio/x-float-array ] I20170411-18:23:40.576(10)? code: 400,
> I20170411-18:23:40.576(10)? code_description: 'Bad Request',
> I20170411-18:23:40.577(10)? error: 'unable to transcode data stream
> audio/wav -> audio/x-float-array ' }
The content type sample rate seems correct:
Any ideas please?
This is due to watson thinking that the audio file you're trying to upload is not a audio file, So to protect itself from harful file it raises exception
official explanation : link
corrupted file : file byte code altered (scan before downloading)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With