pywin32 and pyttsx error, trouble combining the two

╄→гoц情女王★ 提交于 2019-12-13 06:31:46

问题


i have pywin32 in my site packages and my pyttsx is in a separate folder. Is this the reason why i am getting the following error?

import win32api, sys, os
ImportError: DLL load failed: The specified module could not be found

The code is as follows,

import pyttsx
def onStart(name):
    print 'starting', name
def onWord(name, location, length):
    print 'word', name, location, length
def onEnd(name, completed):
    print 'finishing', name, completed
engine = pyttsx.init()
engine.connect('started-utterance', onStart)
engine.connect('started-word', onWord)
engine.connect('finished-utterance', onEnd)
engine.say('The quick brown fox jumped over the lazy dog.')
engine.runAndWait()

from here, http://pyttsx.readthedocs.org/en/latest/engine.html#examples

My pywin32 is from here,

http://sourceforge.net/projects/pywin32/files/pywin32/Build%20219/

for Py 2.7


回答1:


The problem was that the file

pywintypes27.dll

was not in the right directory. It had to be in

'C:\Windows\System32'

@CristiFati




回答2:


Use the pyttsx3 module instead . It supports both python3 and python2.

To install:

pip install pyttsx3.

It automatically installs those win32 and other dependencies.



来源:https://stackoverflow.com/questions/31659695/pywin32-and-pyttsx-error-trouble-combining-the-two

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!