Gtts
Gtts is a module for Python that let’s you use the Google API with text-to-speech tools, so useful to translate or get an audio from text. I’ve talked about this modules in many posts and videos; I will put some links here:
- From text to mp3 with gtts (reading external file) 16.8.2019
- Creare file mp3 da file di testo con gtts
- If you get an error using gtts module 26.9.2018
- Google text-to-speech : example of GUI to create mp3 from text 4.8.2018
- Google Text to Speech API: how to create mp3 with text in any language 15.4.2018
Error due to need to upgrade requests
If you have this error (it happened to me using the gtts module, but can occur with other modules that uses requests too),
TypeError: __init__() got an unexpected keyword argument ‘strict’
upgrad the requests module with pip:
pip install requests –upgrade
Basic use of gtts
If you don’t know how to use gtts, I will show you a little example of the code.
To install it on pc use
pip install gtts
To install it on the mac
pip3 install gtts
import gtts import os tts = gtts.gTTS("Hello", "en") tts.save("Hello.mp3") os.startfile("Hello.mp3")
Error ‘key’
A recent error (19.9.19) can be avoided with the method in this link.