Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working pyttsx3 on macos . #297

Open
ganeshnikhil opened this issue Nov 24, 2023 · 13 comments
Open

Not working pyttsx3 on macos . #297

ganeshnikhil opened this issue Nov 24, 2023 · 13 comments

Comments

@ganeshnikhil
Copy link

i am using pyttsx3 on macos and python version that i am using is 3.9.0 64bit . i am getting this error on both imac and mac book air .

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyttsx3/init.py", line 20, in init
eng = _activeEngines[driverName]
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/weakref.py", line 134, in getitem
o = self.datakey
KeyError: None

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/Shared/python_code/youtube_summarizer/test.py", line 15, in
text_to_speech(text)
File "/Users/Shared/python_code/youtube_summarizer/test.py", line 5, in text_to_speech
speaker = pyttsx3.init()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyttsx3/init.py", line 22, in init
eng = Engine(driverName, debug)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyttsx3/engine.py", line 30, in init
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyttsx3/driver.py", line 50, in init
self._module = importlib.import_module(name)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1030, in _gcd_import
File "", line 1007, in _find_and_load
File "", line 986, in _find_and_load_unlocked
File "", line 680, in _load_unlocked
File "", line 790, in exec_module
File "", line 228, in _call_with_frames_removed
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyttsx3/drivers/nsss.py", line 12, in
class NSSpeechDriver(NSObject):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyttsx3/drivers/nsss.py", line 13, in NSSpeechDriver
@objc.python_method
NameError: name 'objc' is not defined

@puchengy
Copy link

same for me.

@senthilkumarimuth
Copy link

same for me as well

@onyekaokonji
Copy link

Installing this package solved the challenge for me.

@adriandlai
Copy link

thanks @onyekaokonji this worked for me

@drewpeterson1
Copy link

I was experiencing the same issue, and that seemed to resolve that issue.

Now I received a new error (below). Do you have an idea on how to address?

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyttsx3/init.py", line 20, in init
eng = _activeEngines[driverName]
~~~~~~~~~~~~~~^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/weakref.py", line 136, in getitem
o = self.datakey
~~~~~~~~~^^^^^
KeyError: None

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/drewpeterson/Documents/Programming/Python/CS50/speech.py", line 6, in
engine = pyttsx3.init()
^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyttsx3/init.py", line 22, in init
eng = Engine(driverName, debug)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyttsx3/engine.py", line 30, in init
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyttsx3/driver.py", line 50, in init
self._module = importlib.import_module(name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/init.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1381, in _gcd_import
File "", line 1354, in _find_and_load
File "", line 1325, in _find_and_load_unlocked
File "", line 929, in _load_unlocked
File "", line 994, in exec_module
File "", line 488, in _call_with_frames_removed
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyttsx3/drivers/nsss.py", line 2, in
from Foundation import *
File "", line 1403, in _handle_fromlist
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/objc/_lazyimport.py", line 160, in getattr
value = self.__calc_all()
^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/objc/_lazyimport.py", line 328, in __calc_all
all_names.update(p.all)
^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/objc/_lazyimport.py", line 160, in getattr
value = self.__calc_all()
^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/objc/_lazyimport.py", line 257, in __calc_all
objc.loadBundleVariables(self.__bundle, dct, varmap)
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/objc/_pythonify.py", line 52, in numberWrapper
if isinstance(obj, NSDecimalNumber):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
objc.internal_error: PyObjC: internal error in _type_lookup at Modules/objc/objc-object.m:380: assertion failed: dict && PyDict_Check(dict)

@senthilkumarimuth
Copy link

Installing this package solved the challenge for me.

This worked for me as well. Thanks a lot

@dhavalvoraa
Copy link

Installing this package solved the challenge for me.

This worked for me as well, however the single line speak command does not work , so must set up engine and use the say command.

@scorpionLinq
Copy link

Installing this package solved the challenge for me.

这个有用

@se7enack
Copy link

Still not working for me.
`
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyttsx3/init.py", line 24, in init
eng = _activeEngines[driverName]
~~~~~~~~~~~~~~^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/weakref.py", line 136, in getitem
o = self.datakey
~~~~~~~~~^^^^^
KeyError: None

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyttsx3/init.py", line 27, in init
eng = Engine(driverName=driverName, debug=debug)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyttsx3/engine.py", line 32, in init
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyttsx3/driver.py", line 51, in init
self._module = importlib.import_module(name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/init.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1387, in _gcd_import
File "", line 1360, in _find_and_load
File "", line 1331, in _find_and_load_unlocked
File "", line 935, in _load_unlocked
File "", line 994, in exec_module
File "", line 488, in _call_with_frames_removed
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyttsx3/drivers/nsss.py", line 35, in
class NSSpeechDriver(NSObject):
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyttsx3/drivers/nsss.py", line 42, in NSSpeechDriver
@objc.python_method
^^^^
NameError: name 'objc' is not defined. Did you mean: 'object'?

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/user/Desktop/tty.py", line 5, in
engine = pyttsx3.init()
^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyttsx3/init.py", line 31, in init
raise RuntimeError("\n\nUnable to load driver '%s'" % driverName)
RuntimeError:

Unable to load driver 'None'
`

@holytony
Copy link

i am using pyttsx3 on macos and python version that i am using is 3.9.0 64bit . i am getting this error on both imac and mac book air .

Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyttsx3/init.py", line 20, in init eng = _activeEngines[driverName] File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/weakref.py", line 134, in getitem o = self.datakey KeyError: None

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/Shared/python_code/youtube_summarizer/test.py", line 15, in text_to_speech(text) File "/Users/Shared/python_code/youtube_summarizer/test.py", line 5, in text_to_speech speaker = pyttsx3.init() File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyttsx3/init.py", line 22, in init eng = Engine(driverName, debug) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyttsx3/engine.py", line 30, in init self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyttsx3/driver.py", line 50, in init self._module = importlib.import_module(name) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1030, in _gcd_import File "", line 1007, in _find_and_load File "", line 986, in _find_and_load_unlocked File "", line 680, in _load_unlocked File "", line 790, in exec_module File "", line 228, in _call_with_frames_removed File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyttsx3/drivers/nsss.py", line 12, in class NSSpeechDriver(NSObject): File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyttsx3/drivers/nsss.py", line 13, in NSSpeechDriver @objc.python_method NameError: name 'objc' is not defined

try to uninstall you pyobjc then install 9.X version, see if it works

@gsj011014
Copy link

第一步:pip install pyttsx4
第二步:修改 xxxxxxx/site-packages/pyttsx4/drivers/nsss.py 文件,在头部添加代码 import objc
这样就可以正常工作了~

@willwade
Copy link

willwade commented May 3, 2024

Personally pyttsx4 deviates quite a bit - the coqui stuff is ok. but its a bit of a overhead - this is cleaner IMHO https://github.com/thevickypedia/py3-tts (although they could do with stating its a fork)

@chelizichen
Copy link

Installing this package solved the challenge for me.

cool ! it works success on my mac machine!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests