An example of using the MS Speech SDK to implement TTS (Text-To-Speech).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # speak.py
#
# Repeats what user types.
#
# Make sure you have MS Speech SDK installed
# and registered with the MakePy tool in PythonWin.
#
import sys
from win32com.client import constants
import win32com.client
speaker = win32com.client.Dispatch("SAPI.SpVoice")
print "Type word or phrase, then enter."
print "Ctrl+Z then enter (dos/win32) or Ctrl+D (unix) to exit."
while 1:
try:
s = raw_input()
speaker.Speak(s)
except:
if sys.exc_type is EOFError:
sys.exit()
|
This is fun, you could make a Dr. Sbaitso clone if you throw some Markov chains in.