pyttsx pyttsx.init() 不工作 [英] pyttsx pyttsx.init() not working

查看:18
本文介绍了pyttsx pyttsx.init() 不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

So I am making a Chatbot/Virtual assistant with Python, I was searching for a text-to-speech engine for Python and found pyttsx. I downloaded it with pip (like this: sudo pip install pyttsx ) (btw I am using Linux). I am using Python 2.7 (I tried with python 3.5 gave me the same error). I imported it and it worked but when I put (as this tutorial "told me" to 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 引擎如果您能提供帮助,请提前感谢.

Any help would be good, or suggest a nother txt-to-speech engine Thx in advance if you can help.

推荐答案

您必须安装 espeak 1:

You have to install espeak 1st:

sudo apt-get install espeak

这篇关于pyttsx pyttsx.init() 不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆