自言自语

I'm Wang Xianyuan, writing for myself, more studying, more experience…

Python几行代码实现英文朗读

By

需要安装 pywin32 模块。

#-*- encoding: gb18030 -*-
import sys
from win32com.client import constants
import win32com.client

speaker = win32com.client.Dispatch("SAPI.SpVoice")
print "在下面输入英文单词或者英文字母,也可以是句子,输完按回车进行下一行输入。"
print "如果想退出按Ctrl+Z"

while 1:
  try:
    s = raw_input()
    speaker.Speak(s)
  except:
    if sys.exc_type is EOFError:
      sys.exit()

Comments are closed.