Search code examples
node.jsibm-cloudibm-watsonspeech-to-textibm-cloud-speech

IBM Watson Speech-to-Text "Recognize audio" method?


How is the recognize method used to send an audio files to Speech-to-Text for transcription? Where is the audio file accessed? Is there somewhere to put a path to a local file, a Google Storage location, or a download URL?

The documentation says:

enter image description here

OK, that's what I want to do! The documentation says that this is the method:

recognize(params, [callback()])

The params I see are:

var params = {
  objectMode: true,
  contentType: 'audio/flac',
  model: 'en-US_BroadbandModel',
  keywords: ['colorado', 'tornado', 'tornadoes'],
  keywordsThreshold: 0.5,
  maxAlternatives: 3
};

Is there a parameter for MediaFileUri?


Solution

  • Your link is to the node.js sdk documentation. In which case the audio is sent as the parameter audio, which should be either a NodeJS.ReadableStream or a buffer. You can create a readable stream from a url in which case you could add:

    
    params.audio = fs.createReadStream(url);
    
    

    that will require the url to point at an audio file, and not a disguised webpage with an audio player.