1

I use pyttsx3 in heroku, but I can't initialize it in remote environment(heroku). I can do it in the local environment(Windows).

How can I solve this problem?


in log

2021-08-17T03:25:22.000000+00:00 app[api]: Build started by user ***
2021-08-17T03:26:37.200078+00:00 app[api]: Deploy 97a8e496 by user ***
2021-08-17T03:26:37.200078+00:00 app[api]: Release v32 created by user ***
2021-08-17T03:26:39.968771+00:00 heroku[web.1]: State changed from crashed to starting
2021-08-17T03:26:51.000000+00:00 app[api]: Build succeeded
2021-08-17T03:26:53.025542+00:00 heroku[web.1]: Starting process with command `python app.py`
2021-08-17T03:26:54.961078+00:00 app[web.1]: Traceback (most recent call last):
2021-08-17T03:26:54.961098+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/pyttsx3/__init__.py", line 20, in init
2021-08-17T03:26:54.961183+00:00 app[web.1]: eng = _activeEngines[driverName]
2021-08-17T03:26:54.961195+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/weakref.py", line 134, in __getitem__
2021-08-17T03:26:54.961324+00:00 app[web.1]: o = self.data[key]()
2021-08-17T03:26:54.961351+00:00 app[web.1]: KeyError: None
2021-08-17T03:26:54.961353+00:00 app[web.1]:
2021-08-17T03:26:54.961353+00:00 app[web.1]: During handling of the above exception, another exception occurred:
2021-08-17T03:26:54.961353+00:00 app[web.1]:
2021-08-17T03:26:54.961362+00:00 app[web.1]: Traceback (most recent call last):
2021-08-17T03:26:54.961371+00:00 app[web.1]: File "/app/app.py", line 2, in <module>
2021-08-17T03:26:54.961467+00:00 app[web.1]: engline = pyttsx3.init()
2021-08-17T03:26:54.961475+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/pyttsx3/__init__.py", line 22, in init
2021-08-17T03:26:54.961555+00:00 app[web.1]: eng = Engine(driverName, debug)
2021-08-17T03:26:54.961563+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/pyttsx3/engine.py", line 30, in __init__
2021-08-17T03:26:54.961635+00:00 app[web.1]: self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
2021-08-17T03:26:54.961644+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/pyttsx3/driver.py", line 50, in __init__
2021-08-17T03:26:54.961725+00:00 app[web.1]: self._module = importlib.import_module(name)
2021-08-17T03:26:54.961733+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/importlib/__init__.py", line 127, in import_module
2021-08-17T03:26:54.961831+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2021-08-17T03:26:54.961841+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
2021-08-17T03:26:54.961921+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
2021-08-17T03:26:54.961975+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
2021-08-17T03:26:54.962025+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
2021-08-17T03:26:54.962079+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 850, in exec_module
2021-08-17T03:26:54.962142+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
2021-08-17T03:26:54.962196+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/pyttsx3/drivers/espeak.py", line 9, in <module>
2021-08-17T03:26:54.962286+00:00 app[web.1]: from . import _espeak, toUtf8, fromUtf8
2021-08-17T03:26:54.962297+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/pyttsx3/drivers/_espeak.py", line 18, in <module>
2021-08-17T03:26:54.962381+00:00 app[web.1]: dll = cdll.LoadLibrary('libespeak.so.1')
2021-08-17T03:26:54.962388+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/ctypes/__init__.py", line 452, in LoadLibrary
2021-08-17T03:26:54.962520+00:00 app[web.1]: return self._dlltype(name)
2021-08-17T03:26:54.962522+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/ctypes/__init__.py", line 374, in __init__
2021-08-17T03:26:54.962623+00:00 app[web.1]: self._handle = _dlopen(self._name, mode)
2021-08-17T03:26:54.962640+00:00 app[web.1]: OSError: libpulsecommon-13.99.so: cannot open shared object file: No such file or directory
2021-08-17T03:26:55.023809+00:00 heroku[web.1]: Process exited with status 1
2021-08-17T03:26:55.111644+00:00 heroku[web.1]: State changed from starting to crashed

file structure

/
|-- app.py
|-- requirements.txt
|-- Aptfile
|-- Procfile

buildpacks

  • heroku-community/apt
  • heroku/python

in app.py

import pyttsx3
engine = pyttsx3.init()

in requirements.txt

pyttsx3==2.90
comtypes==1.1.10

in Procfile

web: python app.py

in Aptflie

libespeak1
espeak
ffmpeg

What I tried

  • add libpulse0 to Procfile
  • add libpulse-dev to Procfile
  • change engine = pyttsx3.init() to engine = pyttsx3.init('espeak') in app.py
  • change pyttsx3==2.90 to pyttsx3==2.71 in requirements.txt
misoshiru
  • 11
  • 3

0 Answers0