How to make Python speak

install pip install pypiwin32

How to use the text to speech features of a Windows PC

from win32com.client import Dispatch

speak = Dispatch("SAPI.SpVoice").Speak

speak("Ciao")

Using google text-to-speech Api to create an mp3 and hear it

After you installed the gtts module in cmd: pip install gtts

from gtts import gTTS
import os    

tts = gTTS(text="This is the pc speaking", lang='en')
tts.save("pcvoice.mp3")
# to start the file from python
os.system("start pcvoice.mp3")

You should try using the PyTTSx package since PyTTS is outdated. PyTTSx works with Python 2. For Python 3, install the PyTTSx3 package.

http://pypi.python.org/pypi/pyttsx/

https://pypi.org/project/pyttsx3/


A bit cheesy, but if you use a mac you can pass a terminal command to the console from python.

Try typing the following in the terminal:

$ say 'hello world' 

And there will be a voice from the mac that will speak that. From python such a thing is relatively easy:

import os
os.system("echo 'hello world'")
os.system("say 'hello world'") 

The python-espeak package is available in Debian, Ubuntu, Redhat, and other Linux distributions. It has recent updates, and works fine.

from espeak import espeak
espeak.synth("Hello world.")

Jonathan Leaders notes that it also works on Windows, and you can install the mbrola voices as well. See the espeak website at http://espeak.sourceforge.net