text to speech – How to make Python speak

text to speech – How to make Python speak

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



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) 

text to speech – How to make Python speak

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


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)
# to start the file from python
os.system(start pcvoice.mp3)

Leave a Reply

Your email address will not be published.