gpt4 book ai didi

python - pyttsx pyttsx.init() 不工作

转载 作者:行者123 更新时间:2023-11-28 21:04:46 25 4
gpt4 key购买 nike

所以我正在用 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

任何帮助都会很好,或者建议另一个文本到语音引擎如果您能提供帮助,请提前致谢。

最佳答案

你必须先安装 espeak:

sudo apt-get install espeak

关于python - pyttsx pyttsx.init() 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44890310/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com