Gtts module – TypeError: __init__() got an unexpected keyword argument ‘strict’

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:

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.

Published by pythonprogramming

Started with basic on the spectrum, loved javascript in the 90ies and python in the 2000, now I am back with python, still making some javascript stuff when needed.