每当我尝试在 python 3.8.6 中运行我的文本到语音程序时
它给了我错误
我的代码
import pyttsx3
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
print(voices[0].id)
print(voices)
engine.setProperty('voices', voices[0].id)
engine.say("hello")
engine.runAndWait()
错误
Traceback (most recent call last):
File "C:/Users/Admin/PycharmProjects/automating_Practices/Chat_Bot_PRogram/Voice_chatbot.py", line 20, in <module>
voices = engine.getProperty('voices')
File "C:\Python\Python386\lib\site-packages\pyttsx3\engine.py", line 146, in getProperty
return self.proxy.getProperty(name)
File "C:\Python\Python386\lib\site-packages\pyttsx3\driver.py", line 173, in getProperty
return self._driver.getProperty(name)
File "C:\Python\Python386\lib\site-packages\pyttsx3\drivers\sapi5.py", line 88, in getProperty
return [self._toVoice(attr) for attr in self._tts.GetVoices()]
File "C:\Python\Python386\lib\site-packages\pyttsx3\drivers\sapi5.py", line 88, in <listcomp>
return [self._toVoice(attr) for attr in self._tts.GetVoices()]
File "C:\Python\Python386\lib\site-packages\pyttsx3\drivers\sapi5.py", line 77, in _toVoice
return Voice(attr.Id, attr.GetDescription())
_ctypes.COMError: (-2147200966, None, (None, None, None, 0, None))
请任何人都可以帮我解决这个问题