Python 3.7: install win32com modules and make pc talk

We can make the pc talk on window with a code like the one below, using the win32com module.

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 to exit.")
while 1:
   try:
      s = input()
      speaker.Speak(s)
   except:
         sys.exit()

 

 


Published by pythonprogramming

Started with basic on the spectrum, loved javascript in the 90ies and python in the 2000, now I am back with python, still making some javascript stuff when needed.