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?
content-type
andcontent-length
that s3 returns. I bet that you could save the file in a temp folder and then send it to speech to text. In this case, you need to make sure you can override the headers to send to STT and that they match what the API is expecting. – German Attanasio