gpt4 book ai didi

Python错误: No module named 'engine'

转载 作者:太空宇宙 更新时间:2023-11-03 15:44:53 26 4
gpt4 key购买 nike

我正在尝试将 SpeechRecognition STT 模块用于正在编码的 AI,并且我也在使用 Pyttsx,但出现此错误。

 File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pyttsx/__init__.py", line 18, in <module>
from engine import Engine
ImportError: No module named 'engine'

很多人都试图回答这个问题,对于所有遇到这个问题的人来说,但答案没有解释或不起作用!

这是我的代码

import speech_recognition
import pyttsx

speech_engine = pyttsx.init('sapi5') # see http://pyttsx.readthedocs.org/en/latest/engine.html#pyttsx.init
speech_engine.setProperty('rate', 150)

def speak(text):
speech_engine.say(text)
speech_engine.runAndWait()

recognizer = speech_recognition.Recognizer()

def listen():
with speech_recognition.Microphone() as source:
recognizer.adjust_for_ambient_noise(source)
audio = recognizer.listen(source)

try:
return recognizer.recognize_sphinx(audio)
# or: return recognizer.recognize_google(audio)
except speech_recognition.UnknownValueError:
print("Could not understand audio")
except speech_recognition.RequestError as e:
print("Recog Error; {0}".format(e))

return ""



speak("Say something!")
speak("I heard you say " + listen())

如果有人可以解释并解决我的问题,那会很有帮助谢谢!

最佳答案

点击此链接。它具有与 python 3 兼容的所有更新。 https://github.com/jpercent/pyttsx

关于Python错误: No module named 'engine' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41842703/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com