所以我正在用 Python 做一个聊天机器人/虚拟助手,我正在寻找 Python 的文本到语音引擎并找到了 pyttsx。我用 pip 下载了它(像这样:sudo pip install pyttsx
)(顺便说一句,我使用的是Linux)。我正在使用 Python 2.7(我尝试使用 python 3.5 给了我同样的错误)。我导入了它并且它起作用了,但是当我把它(本教程“告诉我”到https://pythonspot.com/en/speech-engines-with-python-tutorial/)时engine = pyttsx.init()
。
代码如下所示:
import pyttsx
engine = pyttsx.init()
engine.say('Hello There')
engine.runAndWait()
这是我得到的错误:
Traceback (most recent call last):
File "/home/theshoutingparrot/Desktop/Programming/Python/Bots/A.I/speechtotext.py", line 2, in <module>
engine = pyttsx.init()
File "/usr/local/lib/python2.7/dist-packages/pyttsx/__init__.py", line 39, in init
eng = Engine(driverName, debug)
File "/usr/local/lib/python2.7/dist-packages/pyttsx/engine.py", line 45, in __init__
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "/usr/local/lib/python2.7/dist-packages/pyttsx/driver.py", line 64, in __init__
self._module = __import__(name, globals(), locals(), [driverName])
File "/usr/local/lib/python2.7/dist-packages/pyttsx/drivers/espeak.py", line 19, in <module>
import _espeak
File "/usr/local/lib/python2.7/dist-packages/pyttsx/drivers/_espeak.py", line 24, in <module>
dll = cdll.LoadLibrary('libespeak.so.1')
File "/usr/lib/python2.7/ctypes/__init__.py", line 440, in LoadLibrary
return self._dlltype(name)
File "/usr/lib/python2.7/ctypes/__init__.py", line 362, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libespeak.so.1: cannot open shared object file: No such file or directory
任何帮助都会很好,或者如果您可以提供帮助,请提前建议另一个 txt-to-speech 引擎 Thx。