I have tried PyTTS (deprecated) and PyTTSx (the most recommended) and two Google TTS solutions (gTTS and another one by some guy named Hung Truong) but none of them worked under Python 3.4. It seems they haven't been ported to 3.x.
I searched here on StackOverflow and Google, but all the proposed TTS solutions don't work under Python 3. I'm on Windows 7.
A user on Reddit found a solution.
Turns out that gTTS works under Python 3.x, it was me that was importing the module wrong.
I was using:
Resulting in the following error:
When the correct way is:
I just installed gtts 1.0.7 that was uploaded on 2015-10-07
The following code works for me in Python 3.5:
I'm on a Mac using in the inbuilt "afply" to play the mp3 but there are other ways e.g. Playing mp3 song on python
Rather than using a module, you could use Google Text-to-Speech API . You can easily use this URL to generate a wav file and get it through a simple HTTP request:
http://www.translate.google.com/translate_tts?tl=en&q=Hello%20World
The best solution for that is :
pyttsx3
Pyttsx3 is an offline cross-platform Test-to-Speech library which is compatible with both Python 3 and Python 2 and supports multiple TTS engines.
I have found it very useful and there is no delay in sound production unlike gTTS which needs internet connection to work and also has some delay.
To install :
pip install pyttsx3
Here is a sample code :
```
```