I need the messenger audio file, for use in the api Google Cloud Speech API. When an audio is received in the messenger, a url is generated that downloads this file in .mp4. How can I from this url retrieve the audio, and use it in the Google API?
I need the messenger audio file, for use in the api Google Cloud Speech API. When an audio is received in the messenger, a url is generated that downloads this file in .mp4. How can I from this url retrieve the audio, and use it in the Google API?
The trick here is to get into streams, with the http (or equivalent) module to download the audio file and then pipe to a stream, and then do whatever you want. In this example, save to a file:
var http = require('http');
var fs = require('fs');
var audioUrl = "http://www.exemplo/audio.mp4",
fileName = "audio.mp4";
var file = fs.createWriteStream(fileName);
var request = http.get(audioUrl, function(response) {
response.pipe(file);
});