A small routine (compiled by Python) for exercise about English phrases in the field of computer.
- python2.* / python3.*
- pywin32
- speech
https://sourceforge.net/projects/pywin32/files/pywin32/Build%20221/,根据 **Python版本(2.*/3.*)**和 CPU位数(32位/64位)下载相应版本安装
比如,像我这种情况,就需要安装 pywin32-221.win-amd64-py3.7.exe
pip install speech
对于Python3用户,安装完speech模块后,需要去修改 speech.py文件,该文件路径在..\Python37\Lib\site-packages
下
- line59 修改
import thread
,改成import threading
; - line157 修改
print prompt
,改成print(prompt)
; - 对最后的函数
_ensure_event_thread
修改如下:
class T(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
def run(self):
pass
def _ensure_event_thread():
"""
Make sure the eventthread is running, which checks the handlerqueue
for new eventhandlers to create, and runs the message pump.
"""
global _eventthread
if not _eventthread:
def loop():
while _eventthread:
pythoncom.PumpWaitingMessages()
if _handlerqueue:
(context,listener,callback) = _handlerqueue.pop()
# Just creating a _ListenerCallback object makes events
# fire till listener loses reference to its grammar object
_ListenerCallback(context, listener, callback)
time.sleep(.5)
_eventthread = T()
_eventthread.start()