【问题标题】:Error "cannot import name 'COMError'" when I import pyttsx3 and use sapi5 [duplicate]导入 pyttsx3 并使用 sapi5 时出现错误“无法导入名称‘COMError’”[重复]
【发布时间】:2021-10-26 02:40:01
【问题描述】:

当导入 pyttsx3 并使用 sapi5 时,正在引发错误 cannot import name 'COMError'

文本中的代码:

import pyttsx3
import datetime
import comtypes.client as cc


engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
#print (voices)
engine.setProperty('voice',voices[33].id)

def speak(audio):
    engine.say(audio)
    engine.runAndWait()

def wishme():
    hour = int(datetime.datetime.now().hour)
    if hour >=0 and hour <12:
        speak = ("Good Morning!")

    elif hour >=12 and hour <18:
        speak = ("Good afternoon!")

    else:
        speak = ("Good evening!")
        speak = ("I am Ryuga better then siri how may I help you")


if __name__ == '__main__':
    wishme()

图片中的代码:

这是错误:

/usr/local/bin/python3 /Users/sidd/Desktop/jarvis/Jarvis.py
Traceback (most recent call last):
  File "/Users/sidd/Desktop/jarvis/Jarvis.py", line 3, in <module>
    import comtypes.client as cc
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/comtypes/__init__.py", line 23, in <module>
    from _ctypes import COMError
ImportError: cannot import name 'COMError'

【问题讨论】:

标签: python artificial-intelligence voice-recognition voice pyttsx3


【解决方案1】:
猜你喜欢
  • 1970-01-01
  • 2016-09-06
  • 1970-01-01
  • 1970-01-01
  • 2017-11-10
  • 2015-10-05
  • 2017-08-11
  • 2021-02-19
  • 2014-01-29
相关资源
最近更新 更多