A New Look at Python Speech

vegaseat 3 Tallied Votes 305 Views Share

A somewhat newer look at Peter Parente's pywin32 based speech engine. It will read text on your computer.

''' pyttsx_speech_engine1.py
speak a text test-program, adjust speak rate (try 200 +- 120)
and volume (0.0 to 1.0)

download
pyttsx-1.1.tar.gz
from
http://pypi.python.org/pypi/pyttsx
extract and run setup.py install
this in turn needs setuptools from
http://pypi.python.org/pypi/setuptools

docs at:
http://pyttsx.readthedocs.org/en/v1.1/

this program also needs pywin32 installed, eg.
pywin32-216.win32-py2.7.exe

tested with Python273  by  vegaseat  12feb2013
'''

import pyttsx
import time

engine = pyttsx.init()

volume = engine.getProperty('volume')
print(volume)
new_volume = volume - 0.25
engine.setProperty('volume', new_volume)

rate = engine.getProperty('rate')
print(rate)
new_rate = rate - 80

engine.setProperty('rate', new_rate)

engine.say('The quick brown fox jumped over the lazy dog.')

# announce the date and time, does a swell job
time_str = "The date and time is " + time.asctime() + "..."
print(time_str)
engine.say(time_str)

time.sleep(1.2)

engine.runAndWait()
ZZucker 342 Practically a Master Poster

Thanks for pointing that pywin32 needs to be installed too!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.