Peter's Blog

Redefining the Impossible

Talking Python


Getting Python to talk with Windows XP:

  • run C:\Python23\Lib\site-packages\win32com\client\makepy.py
  • choose 'Microsoft Speech Object Library (5.0)' from the list and OK
  • run this python
    import win32com.client
    
    o = win32com.client.Dispatch( 'SAPI.Spvoice')
    o.Speak( 'That was easy')
    
  • Combine this with remote sshd login and a loud av amp in church mode and scare the wife.

Talk from command line:

#
# Speak
#
import win32com.client
import sys

win32com.client.Dispatch( 'SAPI.Spvoice').Speak( " ".join( sys.argv[1:]))

Filed under: python windows

wrybread Says:

about 1 year ago

I was wondering if you or someone might know how to use a different voice? Apparently it's using whatever is set to the default voice in Windows control panel under Speech.

Does anyone know how to specify a different voice from Python?

Comments are Closed