繁体   English   中英

pyttsx3 不会在 MacOSX Python 3.9 上返回任何音频

[英]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

大家好,尝试用 pyttsx3 做一个小声乐助手,但即使我改变并尝试了所有解决方案,它仍然不起作用。 错误是

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_'

有人知道该怎么做吗? 谢谢

我运行它没有任何错误。 也许问题出在 python 版本上,我使用的是 3.7.3

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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