pyttsx3: pyttsx3 not working in ubuntu.
when i run the sample pyttsx3 code .
import pyttsx3
engine = pyttsx3.init()
engine.say("hello")
engine.runAndWait()
i get the following error:
Traceback (most recent call last): File “/home/sivaramakrishnan/.local/lib/python3.6/site-packages/pyttsx3/init.py”, line 44, in init eng = _activeEngines[driverName] File “/usr/lib/python3.6/weakref.py”, line 137, in getitem o = self.datakey KeyError: None
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File “speaker.py”, line 3, in <module> engine = pyttsx3.init() File “/home/sivaramakrishnan/.local/lib/python3.6/site-packages/pyttsx3/init.py”, line 46, in init eng = Engine(driverName, debug) File “/home/sivaramakrishnan/.local/lib/python3.6/site-packages/pyttsx3/engine.py”, line 52, in init self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug) File “/home/sivaramakrishnan/.local/lib/python3.6/site-packages/pyttsx3/driver.py”, line 75, in init self._module = importlib.import_module(name) File “/usr/lib/python3.6/importlib/init.py”, line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File “<frozen importlib._bootstrap>”, line 994, in _gcd_import File “<frozen importlib._bootstrap>”, line 971, in _find_and_load File “<frozen importlib._bootstrap>”, line 955, in _find_and_load_unlocked File “<frozen importlib._bootstrap>”, line 665, in _load_unlocked File “<frozen importlib._bootstrap_external>”, line 678, in exec_module File “<frozen importlib._bootstrap>”, line 219, in _call_with_frames_removed File “/home/sivaramakrishnan/.local/lib/python3.6/site-packages/pyttsx3/drivers/espeak.py”, line 5, in <module> from . import _espeak, toUtf8, fromUtf8 File “/home/sivaramakrishnan/.local/lib/python3.6/site-packages/pyttsx3/drivers/_espeak.py”, line 18, in <module> dll = cdll.LoadLibrary(‘libespeak.so.1’) File “/usr/lib/python3.6/ctypes/init.py”, line 426, in LoadLibrary return self._dlltype(name) File “/usr/lib/python3.6/ctypes/init.py”, line 348, in init self._handle = _dlopen(self._name, mode) OSError: libespeak.so.1: cannot open shared object file: No such file or directory
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 23
I finally got the solution , just run
sudo apt install libespeak1
then the bug is fixed. libspeak1 package is needed for running pyttsx3 in ubuntu.I have tried the library in both Windows and Ubuntu. In windows the sounds is good and natural but in ubuntu is crappy and like a robot. Did you experience the same thing?
This might be late but try this on linux -
Try this “sudo apt install libespeak1”
chutiya laptop hai tera
At first type sudo apt-get update && sudo apt-get install espeak (this commands works on debian based distros)
Then type the commands bellow according to your distro . I solved my problem this way.
Debian apt-get install alsa-utils Ubuntu apt-get install alsa-utils Alpine apk add alsa-utils Arch Linux pacman -S alsa-utils
Kali Linux apt-get install alsa-utils CentOS yum install alsa-utils Fedora dnf install alsa-utils Raspbian apt-get install alsa-utils Docker docker run cmd.cat/aplay aplay