Open mxdoerfler opened 6 months ago
@mxdoerfler Hi, I just released a new update that might have fixed it. Sadly, as I do not have a MacBook, I can't support OS X testing. I would appreciate feedback, and see if it works.
Downloaded rlvoice from pip just now but still got the same error. See below. Any other ideas? And is this latest version on pip or only github?
Also I am using python 3.12 is rlvoice compatible?
My code
import rlvoice
engine = rlvoice.init()
The error I got:
KeyError Traceback (most recent call last) File ~/anaconda3/envs/carpentry/lib/python3.12/site-packages/rlvoice/init.py:20, in init(driverName, debug) 19 try: ---> 20 eng = _activeEngines[driverName] 21 except KeyError: File ~/anaconda3/envs/carpentry/lib/python3.12/weakref.py:136, in WeakValueDictionary.getitem(self, key) 135 self._commit_removals() --> 136 o = self.data[key]() 137 if o is None: KeyError: None During handling of the above exception, another exception occurred: NameError Traceback (most recent call last) /Users/mdoerfler/Desktop/CS50/week6/t2s_test.py in line 1 ----> 4 engine = rlvoice.init() File ~/anaconda3/envs/carpentry/lib/python3.12/site-packages/rlvoice/init.py:22, in init(driverName, debug) 20 eng = _activeEngines[driverName] 21 except KeyError: ---> 22 eng = Engine(driverName, debug) 23 _activeEngines[driverName] = eng 24 return eng File ~/anaconda3/envs/carpentry/lib/python3.12/site-packages/rlvoice/engine.py:30, in Engine.init(self, driverName, debug) 20 def init(self, driverName=None, debug=False): 21 """ 22 Constructs a new TTS engine instance. 23 (...) 28 @type debug: bool 29 """ ---> 30 self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug) 31 # initialize other vars 32 self._connects = {} File ~/anaconda3/envs/carpentry/lib/python3.12/site-packages/rlvoice/driver.py:50, in DriverProxy.init(self, engine, driverName, debug) 48 # import driver module 49 name = 'rlvoice.drivers.%s' % driverName ---> 50 self._module = importlib.import_module(name) 51 # build driver instance 52 self._driver = self._module.buildDriver(weakref.proxy(self)) File ~/anaconda3/envs/carpentry/lib/python3.12/importlib/init.py:90, in import_module(name, package) 88 break 89 level += 1 ---> 90 return _bootstrap._gcd_import(name[level:], package, level) File :1381, in _gcd_import(name, package, level) File :1354, in _find_andload(name, import) File :1325, in _find_and_loadunlocked(name, import) File :929, in _load_unlocked(spec) File :994, in exec_module(self, module) File :488, in _call_with_frames_removed(f, *args, **kwds) File ~/anaconda3/envs/carpentry/lib/python3.12/site-packages/rlvoice/drivers/nsss.py:11 7 def buildDriver(proxy): 8 return NSSpeechDriver.alloc().initWithProxy(proxy) ---> 11 class NSSpeechDriver(NSObject): 12 @objc.python_method 13 def initWithProxy(self, proxy): 14 self = super(NSSpeechDriver, self).init() File ~/anaconda3/envs/carpentry/lib/python3.12/site-packages/rlvoice/drivers/nsss.py:12, in NSSpeechDriver() 11 class NSSpeechDriver(NSObject): ---> 12 @objc.python_method 13 def initWithProxy(self, proxy): 14 self = super(NSSpeechDriver, self).init() 15 if self: NameError: name 'objc' is not defined
try doing pip install pyobjc==9.0.1
also try making it in a separate env so that it doesn't conflict with global packages
try doing
pip install pyobjc==9.0.1
Same error in venv.
`Traceback (most recent call last): File "/Users/scottrojas/Desktop/T2S/t2s/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.data[key]() KeyError: None
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/scottrojas/Desktop/T2S/t2s/Text2Speech.py", line 3, in
No issues on my Windows machine. It works as expected.
It's a NSSS driver error for sure, but since I don't have a MacOS I can't help with those. I still try my best. I think it might be an error with the pyobjc library now, though. Can't upgrade to the new versions because they don't support all versions of Python 3. I might just copy the source in my rlvoice project or fork it to work according to the needs of this package. Better yet, if anyone knows of a replacement, that would be helpful.
try doing
pip install pyobjc==9.0.1
I think you are right. I'm using M1 MacBook, I have a pytts3 project with pyobjc 9.0.1 running smoothly, the new one with pyobjc ==10.1 had the some problem, after changing pyobjc back to 9.0.1 manually, it works now.
I'm using python 3.10 and pyttsx3 2.88
Yeah, if it's not detecting objc
then it likely can't find the pyobjc
package or can't read it idk.
Anyone else - check this fork.. https://github.com/thevickypedia/py3-tts
This is my basic code which breaks on the second line 'engine = pyttsx3.init()'
I have tried variations both with 'dummy' and specifying the driver explicity and all give me the same error:
I guess it has something to do with communication between the pyttsx3 and pyobjc packages.
Any ideas highly appreciated since this is beyond me now.