Edit I have found a new way to do this locally that gives excellent results. You can read the guide here /Edit
I’ve been practicing my Spanish recently, and I wanted a tool to output spoken Spanish from a text file as I read along.
I tried a few tools like espeak-NG, pyttsx3 and Festival but the results were a little robotic.
The tool that produced the best results was gTTS. This tool sends written text to Google
Translate’s text-to-speech API and returns the text in spoken audio. There are many languages available (get the full list with gtts-cli --all) and the audio out can either be saved to a file or
sent to stdout.
I want to the audio immediately, so I’m going to send the audio to standard out and pipe it into an audio player that will accept input on stdin; ffplay, provided by the ffmpeg package.
Here is the command I used:
gtts-cli --lang es --file written-text.txt | ffplay -nodisp -
gtts-cli- The command line invocation of gTTS--lang es- The language to read the text in--file written-text.txt- The input text fileffplay- The audio player-nodisp- Disable the graphical display-- Accept the audio from stdin
If you want to save the audio to a file then append --output <file> to the gtts-cli command e.g.:
gtts-cli --lang es --file written-text.txt --output spoken-text.mp3
Keep in mind that this tool needs an internet connection and will send your data to Google.

Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.