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

Closed
ganeshnikhil opened this issue Nov 24, 2023 · 18 comments
Closed

Not working pyttsx3 on macos . #297

ganeshnikhil opened this issue Nov 24, 2023 · 18 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
Collaborator

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!

@NaimurRahman3954
Copy link

I faced the same issue and it drove me crazy until I got here. Thanks, guys.

@nateshmbhat
Copy link
Owner

updated docs to address this and merged many bug fix PRs and published the library. if the issue persists, pls raise another issue.

@AbhashKumar55
Copy link

updated docs to address this and merged many bug fix PRs and published the library. if the issue persists, pls raise another issue.

Traceback (most recent call last):
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python313\Lib\site-packages\pyttsx3_init_.py", line 24, in init
eng = _activeEngines[driverName]
~~~~~~~~~~~~~~^^^^^^^^^^^^
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python313\Lib\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 "C:\Users\LENOVO\AppData\Local\Programs\Python\Python313\Lib\site-packages\pyttsx3_init_.py", line 27, in init
eng = Engine(driverName=driverName, debug=debug)
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python313\Lib\site-packages\pyttsx3\engine.py", line 32, in init
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python313\Lib\site-packages\pyttsx3\driver.py", line 51, in init
self.module = importlib.import_module(name)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python313\Lib\importlib_init
.py", line 88, 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 1022, in exec_module
File "", line 488, in call_with_frames_removed
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python313\Lib\site-packages\pyttsx3\drivers\sapi5.py", line 2, in
import comtypes.client # Importing comtypes.client will make the gen subpackage
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python313\Lib\site-packages\comtypes_init
.py", line 177, in
from comtypes._post_coinit import shutdown
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python313\Lib\site-packages\comtypes_post_coinit_init
.py", line 15, in
from comtypes._post_coinit.unknwn import _shutdown # noqa
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python313\Lib\site-packages\comtypes_post_coinit\unknwn.py", line 371, in
class _compointer_base(c_void_p, metaclass=_compointer_meta):
...<89 lines>...
return value.QueryInterface(cls.com_interface)
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python313\Lib\site-packages\comtypes_post_coinit\unknwn.py", line 93, in new
p = type(_compointer_base)(
^^^^^^^^^^^^^^^^
NameError: name "_compointer_base" is not defined. Did you mean: "_compointer_meta"?

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\Python\problem3.py", line 2, in
engine = pyttsx3.init()
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python313\Lib\site-packages\pyttsx3_init_.py", line 31, in init
raise RuntimeError("\n\nUnable to load driver "%s"" % driverName)
RuntimeError:

Unable to load driver "None"

@willwade
Copy link
Collaborator

Hold on @AbhashKumar55 this doesn’t look to be the same issue as the macOS one. I see you are on windows.

@AbhashKumar55 can you confirm what version of this library you are using. I feel this issue you are raising is dealt with on later versions.

@AbhashKumar55
Copy link

AbhashKumar55 commented Oct 14, 2024

Yeah i"m on my windows and the version of this library is "py3-tts 3.5" but at first i installed version "pyttsx3 2.98" and then "py3-tts 3.5"

Now i"m confused and it"s not working so should i go for "pyttsx4 3.0.15" ?

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