nateshmbhat / pyttsx3

Offline Text To Speech synthesis for python
Mozilla Public License 2.0
2.15k stars 336 forks source link

multiple tracebacks on pyttsx3.init() #112

Closed ItsDrike closed 4 years ago

ItsDrike commented 4 years ago

My System: OS: Arch Linux Kernel: linux 5.6.11.arch1-1

To reproduce: Use pipenv (Virtual enviroment manager for python) to install pyttsx3 Run python REPL:

>>> import pyttsx3
>>> engine = pyttsx3.init()

An error shows:

Traceback (most recent call last):
  File "/home/koumakpet/.local/share/virtualenvs/COVID-19-rHjKY_vQ/lib/python3.8/site-packages/pyttsx3/__init__.py", line 20, in init
    eng = _activeEngines[driverName]
  File "/usr/lib/python3.8/weakref.py", line 131, in __getitem__
    o = self.data[key]()
KeyError: None

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/koumakpet/.local/share/virtualenvs/COVID-19-rHjKY_vQ/lib/python3.8/site-packages/pyttsx3/__init__.py", line 22, in init
    eng = Engine(driverName, debug)
  File "/home/koumakpet/.local/share/virtualenvs/COVID-19-rHjKY_vQ/lib/python3.8/site-packages/pyttsx3/engine.py", line 30, in __init__
    self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
  File "/home/koumakpet/.local/share/virtualenvs/COVID-19-rHjKY_vQ/lib/python3.8/site-packages/pyttsx3/driver.py", line 50, in __init__
    self._module = importlib.import_module(name)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/koumakpet/.local/share/virtualenvs/COVID-19-rHjKY_vQ/lib/python3.8/site-packages/pyttsx3/drivers/espeak.py", line 9, in <module>
    from . import _espeak, toUtf8, fromUtf8
  File "/home/koumakpet/.local/share/virtualenvs/COVID-19-rHjKY_vQ/lib/python3.8/site-packages/pyttsx3/drivers/_espeak.py", line 18, in <module>
    dll = cdll.LoadLibrary('libespeak.so.1')
  File "/usr/lib/python3.8/ctypes/__init__.py", line 451, in LoadLibrary
    return self._dlltype(name)
  File "/usr/lib/python3.8/ctypes/__init__.py", line 373, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libespeak.so.1: cannot open shared object file: No such file or directory

Am I doing something wrong or do I need to install some packages to make this work?

nateshmbhat commented 4 years ago

Can u install espeak?

ItsDrike commented 4 years ago

Installing espeak fixed that (sudo pacman -S espeak), but another error occures when I run engine.runAndWait()

>>> import pyttsx3
>>> engine = pyttsx3.init()
>>> engine.say("I will speak this text")
>>> engine.runAndWait()
sh: aplay: command not found

I tried installing aplay, but I don't see it in pacman repositories nor the AUR. Then I've installed aplay using pipenv install aplay, but that didn't help.

ItsDrike commented 4 years ago

Any followups on this? How can I install aplay on Arch Linux?

J0hnL0cke commented 4 years ago

Having the same issue on Raspberry Pi after installing with pip3, so I don't think it's specific to pipenv.

Dark-Hippo commented 4 years ago

I have the same issue on Window 10 running under venv (Python 3.8.1 if that makes a difference, since the PyPI page only lists up to 3.7

Dark-Hippo commented 4 years ago

I have the same issue on Window 10 running under venv (Python 3.8.1 if that makes a difference, since the PyPI page only lists up to 3.7

Nevermind, just solved it myself by downgrading to version 2.71 from this

J0hnL0cke commented 4 years ago

Downgrading doesn't fix the problem for me, but installing espeak does.

nateshmbhat commented 4 years ago

This issue is addressed in the homepage Readme.md now

xuiqzy commented 4 years ago

Where is it addressed? I can't seem to find it. I also had the aplay errors and had to install alsa-utils on Archlinux to get the aplay command line tool. I have a fully functional normal Gnome setup, but alsa-utils doesn't seem to be already installed for other things, so maybe it is good to mention it somewhere that aplay is needed?