Python3.5环境安装及使用 Speech问题解决(转)

修改speech.py

line59 修改import thread,改成import threading 

line157 修改print prompt,改成print(prompt)

 

对最后的函数_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()

  

如果提示如下报错:见图

执行pip install pypiwin32进行安装

posted @ 2018-06-12 16:38  hsggj  阅读(321)  评论(0编辑  收藏  举报