Converting Audio
Several approaches are available to convert text to speech, but the easiest I’ve come across is an incredibly useful and powerful Python-based library called gtts. You can install it using the pip3 command:
$ sudo pip3 install gtts
Once installed, you can call its command-line interpreter front end in the Terminal, like any other program.
For example, if you wanted to generate a sample TTS file from this gtts-cli utility, you can do so from the Terminal window:
$ gtts-cli "This is a quick test." -o output.mp3
Locate the output.mp3 file in the same directory you ran the command, and using the File Manager desktop app, double-click the file to load and play it in the VLC media player.
Now let’s do the same thing programmatically ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access