Newbie in javascript here, I'm trying to get the output from a simple text-to-speech site (the URL changes to the file location) and play it. After looking online I tried this:
var request = require('request');
function tts(text) {
var r = request.get(`https://tts.cyzon.us/tts?text='${encodeURI(text)}'`, function(err, res, body) {
let audio = new Audio(r.uri.href);
audio.play();
});
}
... which didn't work. How do I actually do this?
audio, video, etc in nodejs can you stored in your db in the form of bytes. You can open a file by creating a readstream and then writing the buffer got from the website to the file. You can then open the file and play the audio