下面的程序给了我一个错误。这是我的程序:
import pyttsx3 as tts
def speak(text):
engine = tts.init("sapi5")
engine.say(text)
engine.runandwait()
speak('Hello user this is a test message.')
这是我收到的错误消息:
Traceback (most recent call last):
File "c:\Users\SIDDHESH\Projects\test.py", line 6, in <module>
speak('Hello user this is a test message.')
File "c:\Users\SIDDHESH\Projects\test.py", line 5, in speak
engine.runandwait()
AttributeError: 'Engine' object has no attribute 'runandwait'
我想指出我的变量被调用engine
,但错误消息说明了一个变量'Engine'
。我还想指出,我正在使用Visual Studio Code来运行我的代码。