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

修改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

相关文章
相关标签/搜索