修改speech.pypython
line59 修改import thread,改爲import threading 函數
line157 修改print prompt,改爲print(prompt)oop
對最後的函數_ensure_event_thread修改以下:見加粗字體字體
增長class類 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替換爲下面兩行; _eventthread = T() _eventthread.start()
若是提示以下報錯:見圖blog
執行pip install pypiwin32進行安裝ip