Search code examples
javascriptnode.jstext-to-speech

Google text-to-speech nodejs


I am trying to code a nodejs application that uses google tts api what my problem is, it returns an url to an audio. I need to be able to hear the text automatically without going to link and playing the audio.


Solution

  • first, install mpv player then try this ==>

    const googleTTS = require("google-tts-api");
    let mpv = require('node-mpv');
    let mpvPlayer = new mpv();
    googleTTS("Hello world", "en",1).then(url => mpvPlayer.load(url));