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()
.
The code looks like this:
import pyttsx
engine = pyttsx.init()
engine.say('Hello There')
engine.runAndWait()
And this is the error I am getting:
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
Any help would be good, or suggest a nother txt-to-speech engine Thx in advance if you can help.
You have to install espeak 1st:
sudo apt-get install espeak
I am working in windows 7, I got the importerror at end when doing the same & engine = pyttsx.init() wasn't working before. I installed pypiwin32 to resolve the importerror for win32com.client. Hope it works for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With