npm i google-tts.js
const GoogleTts = require("google-tts.js")
/*
GoogleTts.getUrl("text", "language codes")
*/
GoogleTts.getUrl("abc", "id").then(console.log)
{
success: true,
url: 'https://translate.google.com/translate_tts?ie=UTF-8&q=abc&tl=id&total=1&idx=0&textlen=24&client=tw-ob&prev=input&ttsspeed=1'
}
const GoogleTts = require("google-tts.js")
/*
GoogleTts.saveFile("text", "language codes", "the location that will be filled by the result mp3. (optional)")
*/
GoogleTts.saveFile("abc", "id", "./src/audio.mp3").then(console.log)
/* console log:
{ success: true, message: 'Saved audio in ./src/audio.mp3' }
*/
/* and
add the resulting file to the location you wrote earlier.
*/
console log:
{ success: true, message: 'Saved audio in ./src/audio.mp3' }
and add the resulting file to the location you wrote earlier.
GoogleTts.saveFile("text", "language codes", "the location that will be filled by the result mp3. (optional)")
GoogleTts.getUrl("text", "language codes")