Closed hobson closed 3 years ago
Looks like you need to install pyobjc: https://github.com/dschep/ntfy/issues/87 on MacOSX.
But setup.py
attempts to detect the platform and install it, but doesn't. Even if you manually pip install pyobjc
it fails. Only way setup.py works for me is to install it in --editable
("develop") mode from source:
$ pip install --editable git+https://github.com/nateshmbhat/pyttsx3.git@master#egg=pyttsx3
For reference, here's the Traceback for the crash on OSX (platform.system() == 'Darwin
) after pip install pyobjc pytssx3
>>> import pyttsx3
>>> engine = pyttsx3.init()
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
~/anaconda3/envs/nlpia/lib/python3.6/site-packages/pyttsx3/__init__.py in init(driverName, debug)
43 try:
---> 44 eng = _activeEngines[driverName]
45 except KeyError:
~/anaconda3/envs/nlpia/lib/python3.6/weakref.py in __getitem__(self, key)
136 self._commit_removals()
--> 137 o = self.data[key]()
138 if o is None:
KeyError: None
During handling of the above exception, another exception occurred:
BadPrototypeError Traceback (most recent call last)
<ipython-input-2-2775bef348bf> in <module>()
----> 1 engine = pyttsx3.init()
~/anaconda3/envs/nlpia/lib/python3.6/site-packages/pyttsx3/__init__.py in init(driverName, debug)
44 eng = _activeEngines[driverName]
45 except KeyError:
---> 46 eng = Engine(driverName, debug)
47 _activeEngines[driverName] = eng
48 return eng
~/anaconda3/envs/nlpia/lib/python3.6/site-packages/pyttsx3/engine.py in __init__(self, driverName, debug)
50 @type debug: bool
51 '''
---> 52 self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
53 # initialize other vars
54 self._connects = {}
~/anaconda3/envs/nlpia/lib/python3.6/site-packages/pyttsx3/driver.py in __init__(self, engine, driverName, debug)
73 # import driver module
74 name = 'pyttsx3.drivers.%s' % driverName
---> 75 self._module = importlib.import_module(name)
76 # build driver instance
77 self._driver = self._module.buildDriver(weakref.proxy(self))
~/anaconda3/envs/nlpia/lib/python3.6/importlib/__init__.py in import_module(name, package)
124 break
125 level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)
127
128
~/anaconda3/envs/nlpia/lib/python3.6/importlib/_bootstrap.py in _gcd_import(name, package, level)
~/anaconda3/envs/nlpia/lib/python3.6/importlib/_bootstrap.py in _find_and_load(name, import_)
~/anaconda3/envs/nlpia/lib/python3.6/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_)
~/anaconda3/envs/nlpia/lib/python3.6/importlib/_bootstrap.py in _load_unlocked(spec)
~/anaconda3/envs/nlpia/lib/python3.6/importlib/_bootstrap_external.py in exec_module(self, module)
~/anaconda3/envs/nlpia/lib/python3.6/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)
~/anaconda3/envs/nlpia/lib/python3.6/site-packages/pyttsx3/drivers/nsss.py in <module>()
8 return NSSpeechDriver.alloc().initWithProxy(proxy)
9
---> 10 class NSSpeechDriver(NSObject):
11 def initWithProxy(self, proxy):
12 self = super(NSSpeechDriver, self).init()
BadPrototypeError: Objective-C expects 1 arguments, Python argument has 2 arguments for <unbound selector say of NSSpeechDriver at 0x113a0e168>
Closed topic with apparent fix for MacOS: (https://github.com/nateshmbhat/pyttsx3/issues/1
I have no access to MacOS and as such can't help with any debugging.
This doesn't appear to be fixed as of version 2.7
======================================================================
ERROR: default_test (__main__.TestPyTTSX)
testFileDetection
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/magregor/.virtualenvs/SIM/lib/python3.6/site-packages/pyttsx3/__init__.py", line 44, in init
eng = _activeEngines[driverName]
File "/Users/magregor/.virtualenvs/SIM/lib/python3.6/weakref.py", line 137, in __getitem__
o = self.data[key]()
KeyError: None
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./test/test_pyttsx.py", line 106, in default_test
ttsengine = tts.init()
File "/Users/magregor/.virtualenvs/SIM/lib/python3.6/site-packages/pyttsx3/__init__.py", line 46, in init
eng = Engine(driverName, debug)
File "/Users/magregor/.virtualenvs/SIM/lib/python3.6/site-packages/pyttsx3/engine.py", line 52, in __init__
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "/Users/magregor/.virtualenvs/SIM/lib/python3.6/site-packages/pyttsx3/driver.py", line 75, in __init__
self._module = importlib.import_module(name)
File "/Users/magregor/.virtualenvs/SIM/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 "/Users/magregor/.virtualenvs/SIM/lib/python3.6/site-packages/pyttsx3/drivers/nsss.py", line 2, in <module>
from Foundation import *
ModuleNotFoundError: No module named 'Foundation'
-------------------- >> begin captured logging << --------------------
root: DEBUG: setUp
root: DEBUG: tearDown
--------------------- >> end captured logging << ---------------------
----------------------------------------------------------------------
Ran 1 test in 0.004s
FAILED (errors=1)
(SIM) ________________________________________________________________________________
| ~/src/SIM @ MAGREGOR-M-W0XX (magregor)
| => pip freeze | grep pytts
pyttsx3==2.7```
I'm looking at the fix above now, will note later.
I don't think the version in the Darwin requirements for pyobjc is high enough. In addition it doesn't install AppKit
Fixed in current version
go to the location of site-packages
there you will have a folder named foundation.
do - >renaming
sudo mv foundation/ Foundation/
this worked for me
go to the location of site-packages
there you will have a folder named foundation.
do - >renaming
sudo mv foundation/ Foundation/
this worked for me
this worked for me too
On Macbook Pro OSX High Sierra 10.13.1, within a conda environment: