The error I'm getting is:
File "/*********************************/venv/lib/python3.10/site-packages/pyttsx3/drivers/nsss.py", line 4, in from AppKit import NSSpeechSynthesizer, objc ImportError: cannot import name 'objc' from 'AppKit'
The relevant code of my nsss file is:
from Foundation import NSObject
from AppKit import NSSpeechSynthesizer, objc
from PyObjCTools import AppHelper
def buildDriver(proxy):
return NSSpeechDriver.alloc().initWithProxy(proxy)
class NSSpeechDriver(NSObject):
@objc.python_method
def initWithProxy(self, proxy):
self = super(NSSpeechDriver, self).init()
if self:
self._proxy = proxy
self._tts = NSSpeechSynthesizer.alloc().initWithVoice_(None)
self._tts.setDelegate_(self)
# default rate
self._tts.setRate_(200)
self._completed = True
return self
As a result of this error, I can't the text-to-speech library the way I want to.
I tried downloading obj through "pip install" and attempted at editing how appkit/nssspeech is imported. I also tried asking ChatGPT multiple times--all attempts failed.
I'd really appreciate it if anyone could help me troubleshoot this issue.
Well, you are trying to import
objc from AppKit, which doesn't existYou should instead do
import objc.