所以我用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
任何帮助都是好的,或者如果你能帮忙的话,提前建议一个其他的文本到语音引擎。
4条答案
按热度按时间mpgws1up1#
您必须安装espeak 1st:
k0pti3hp2#
我在windows 7下工作,我在做同样的操作时得到了输入错误。init()以前不工作。我安装了pypiwin32来解决 win32com.client 的输入错误。希望它对你有用。
zaq34kh63#
我在Ubuntu 18.04中也有相同的
安装
检查一下:
并运行以下代码
3hvapo4f4#
请执行以下操作:
希望这有帮助!