简体   繁体   中英

pyttsx3 wont return any audio on MacOSX Python 3.9

import speech_recognition as sr
import pyttsx3

listener = sr.Recognizer()
engine = pyttsx3.init()
engine.say("Hi Sasha")
engine.say("How can i help you sir ?")
engine.runAndWait()
try:
    with sr.Microphone() as source:
        print('listening...')
        voice = listener.listen(source)
        command = listener.recognize_google(voice)
        command = command.lower()
        if "jarvis" in command:
            print(command)
except:
    pass

Hey everyone, trying to do a little vocal assistant with pyttsx3 but even tho i changed and tried everysolution its still dont work. the error is

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.data[key]()
KeyError: None

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/sashakharoubi/Downloads/Portofolio Sasha/IA/ia.py", line 5, in <module>
    engine = 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 52, in __init__
    self._driver = self._module.buildDriver(weakref.proxy(self))
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyttsx3/drivers/nsss.py", line 9, in buildDriver
    return NSSpeechDriver.alloc().initWithProxy(proxy)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyttsx3/drivers/nsss.py", line 19, in initWithProxy
    self._tts.setDelegate_(self)
AttributeError: 'NoneType' object has no attribute 'setDelegate_'

is anyone know what to do? Thanks

I run it without any errors. Maybe the problem is with the python version, I'm using 3.7.3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM