首先,我使用:
我试图使用pyttsx3,但是我不能用官方的代码示例初始化它。在
import pyttsx3
engine = pyttsx3.init()
engine.say('Just a sample text.')
engine.runAndWait()
第二行给出了一个错误:
AttributeError: module 'pyttsx3' has no attribute 'init'
我用PIP安装了它:
^{pr2}$我试图在安装pypiwin32时修复它,但它仍然不起作用:
pip install pypiwin32
当我执行以下脚本时:
import pyttsx3
print(dir(pyttsx3))
我明白了:
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'pyttsx3']
有这样一个:
drivers (folder)
__pycache__ (folder)
driver.py
engine.py
six.py
voice.py
__init__.py
地址:
C:\Program Files\Python36\Lib\site-packages\pyttsx3
以及文件__init__.py
的内容(我省略了注释):
from .engine import Engine
import weakref
_activeEngines = weakref.WeakValueDictionary()
def init(driverName=None, debug=False):
try:
eng = _activeEngines[driverName]
except KeyError:
eng = Engine(driverName, debug)
_activeEngines[driverName] = eng
return eng
模块pyttsx3似乎没有正确初始化。我希望模块路径中没有名为pyttsx3.py的文件。我发现了一个相关的问题here。在
相关问题 更多 >
编程相关推荐