pyttsx3初始化错误,无法使用pyttsx3

2023-12-03

我在 pyttsx3 中使用 .getproperty('voices') 属性时遇到一些问题。所以我决定卸载它,然后使用 PIP 重新安装它,看看是否可以解决问题。

当我遇到 .getproperty('voices') 错误时的上一个链接:当我尝试访问语音的属性时,为什么 pyttsx3 会出现错误?

现在,当我使用 PIP 再次安装它时,我什至无法初始化它

import pyttsx3
engine = pyttsx3.init()

它给出了这个错误:

Traceback (most recent call last):
  File "C:\Users\saife\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyttsx3\__init__.py", line 20, in init
    eng = _activeEngines[driverName]
  File "C:\Users\saife\AppData\Local\Programs\Python\Python38-32\lib\weakref.py", line 131, in __getitem__
    o = self.data[key]()
KeyError: None

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\saife\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyttsx3\drivers\sapi5.py", line 3, in <module>
    from comtypes.gen import SpeechLib  # comtypes
ImportError: cannot import name 'SpeechLib' from 'comtypes.gen' (C:\Users\saife\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\gen\__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\saife\AppData\Local\Programs\Python\Python38-32\lib\ctypes\__init__.py", line 123, in WINFUNCTYPE
    return _win_functype_cache[(restype, argtypes, flags)]
KeyError: (<class 'ctypes.HRESULT'>, (<class 'comtypes.automation.tagVARIANT'>, <class 'comtypes.LP_POINTER(ISpeechRecoGrammar)'>), 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    engine = pyttsx3.init()
  File "C:\Users\saife\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyttsx3\__init__.py", line 22, in init
    eng = Engine(driverName, debug)
  File "C:\Users\saife\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyttsx3\engine.py", line 30, in __init__
    self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
  File "C:\Users\saife\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyttsx3\driver.py", line 50, in __init__
    self._module = importlib.import_module(name)
  File "C:\Users\saife\AppData\Local\Programs\Python\Python38-32\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\saife\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyttsx3\drivers\sapi5.py", line 6, in <module>
    engine = comtypes.client.CreateObject("SAPI.SpVoice")
  File "C:\Users\saife\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\client\__init__.py", line 250, in CreateObject
    return _manage(obj, clsid, interface=interface)
  File "C:\Users\saife\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\client\__init__.py", line 188, in _manage
    obj = GetBestInterface(obj)
  File "C:\Users\saife\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\client\__init__.py", line 110, in GetBestInterface
    mod = GetModule(tlib)
  File "C:\Users\saife\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\client\_generate.py", line 110, in GetModule
    mod = _CreateWrapper(tlib, pathname)
  File "C:\Users\saife\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\client\_generate.py", line 184, in _CreateWrapper
    mod = _my_import(fullname)
  File "C:\Users\saife\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\client\_generate.py", line 24, in _my_import
    return __import__(fullname, globals(), locals(), ['DUMMY'])
  File "C:\Users\saife\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\gen\_C866CA3A_32F7_11D2_9602_00C04F8EE628_0_5_4.py", line 455, in <module>
    ISpeechRecoContext._methods_ = [
  File "C:\Users\saife\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\__init__.py", line 329, in __setattr__
    self._make_methods(value)
  File "C:\Users\saife\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\__init__.py", line 698, in _make_methods
    prototype = WINFUNCTYPE(restype, *argtypes)
  File "C:\Users\saife\AppData\Local\Programs\Python\Python38-32\lib\ctypes\__init__.py", line 125, in WINFUNCTYPE
    class WinFunctionType(_CFuncPtr):
TypeError: item 1 in _argtypes_ passes a union by value, which is unsupported.

打开命令提示符 写:

pip uninstall pyttsx3

Then:

pip install pyttsx3==2.71

你的问题就会解决。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

pyttsx3初始化错误,无法使用pyttsx3 的相关文章

随机推荐

  • Twig - 动态数组键

    目前正在开发一个基于 Symfony 的工具 我正在迭代一系列配置设置 我想要实现的目标似乎很简单 我正在努力获得一定的价值 但其中一个键必须是动态的 下面是一个没有动态密钥的工作示例 set id tmod config content
  • 什么是“访问器功能”?

    In 第 4 3 26 节标准 ECMA 262 版本的 根据属性的形式 可以表示值 直接作为数据值 原始值 对象或 函数对象 或间接通过一对访问器函数 我不明白 访问器函数 是什么意思 也没有在规范中找到访问器函数的定义 然后我在网上搜索
  • 如何在 Python 中使用 Selenium 编辑 CodeMirror?

    每次尝试将文本插入网页上的 CodeMirror 时 我都会收到以下错误消息 有谁知道如何使用selenium成功编辑codemirror WebDriverException Message unknown error Cannot re
  • OpenMP:深度优先搜索的好策略

    我正在编写一个 C 程序 该程序对封闭的骑士之旅 代码是here 我想使用 OpenMP 并行化它 我的问题是以一种创建足够程度的并行性的方式来做到这一点 现在相关部分我的代码看起来像这样 pragma omp parallel for r
  • Emacs:符号作为变量的值为空

    这是我的 emacs file setq default c basic offset 4 c default style linux setq default tab width 4 indent tabs mode t define k
  • 如何确定何时收到蓝牙文件?

    在我的应用程序中 我需要在收到蓝牙传输的文件后对其进行编辑 为了查明何时通过蓝牙接收到文件 我必须使用 BroadcastReceiver 监听什么 Intent 另外 请告诉我是否还有其他解决方案 如果用户通过 Android 操作系统获
  • 每个方面图的 Binwidth 不同

    试图理解分配唯一的binwidth对于每个因子水平geom histogram 但到目前为止还是失败了 这是可重现的数据 a lt rnorm 10 7 0 1 b lt rnorm 10 13 5 df lt data frame dat
  • 当我尝试在内核中使用 printf() 时出现错误

    我使用的是 Visual Studio 2010 和具有计算能力 2 0 的 GTX480 我尝试将 sm 设置为 2 0 但是当我尝试在内核中使用 printf 时 我得到 错误 从 device global 调用主机函数 printf
  • ACR122U NFC读写器频繁断线

    当我将 SIII Android 4 3 放在 ACR122U NFC 读卡器上时 LED 持续闪烁绿色 当我将 Samsung S4 Android 4 3 放入读卡器时 LED 会变绿直到手机位于读卡器上 在这两种情况下 NFC 均已打
  • Python OOP 和列表

    我是 Python 新手 它是 OOP 的东西 无法让它工作 这是我的代码 class Tree root None data def init self equation self root equation def appendLeft
  • 设置触发器以在每月的最后一个小时运行函数

    在谷歌脚本中 我知道有按日期运行的触发器 但我认为这不会起作用 因为每月的天数不同 所以我想知道是否有办法设置触发器在每月最后一个晚上 11 点运行 无论是 30 还是 31 Thanks 首先从项目创建一个触发器编辑 gt 当前项目的触发
  • 是否可以从管道步骤动态设置 Jenkins 作业参数?

    我有以下 简化的 Jenkins 管道代码 jobParams groovy List get Object paramVars def params params choice choices branch tag name RELEAS
  • WCFTestClient HTTP 请求未经客户端身份验证方案“匿名”的授权

    我创建了一项 WCF 服务并将其部署在服务器上 当我浏览此服务时 它会通过 wsdl URL 给出积极响应 现在我正在尝试通过 WCF 测试客户端测试该服务 它显示了正确的元数据 但是 当我尝试从服务中调用任何方法时 它会显示一个异常 这是
  • 使用 NSCoder 保存自己的类

    我正在尝试将一些自定义类 数据存储到我的 iPhone iPad 应用程序中的文件中 我有一个 RSHighscoreList 类 interface RSHighscoreList NSObject NSMutableArray list
  • 从看板中过滤史诗

    首先我想说我已经读过集会看板 隐藏史诗故事但我在根据估算板应用程序的过滤过程实现过滤器时仍然遇到麻烦 目前 我正在尝试将项目过滤器添加到我的纸板的查询对象中 查询对象调用 this getItems 以返回要从中进行筛选的项目数组 据我所知
  • 电子邮件验证器

    我的电子邮件验证码出现问题 我不断收到我的函数未定义的错误 我为java代码制作了一个javascript文件 然后我在html中使用了onchange来触发该函数
  • XML 解析错误:找不到元素位置:http://localhost:8081/web-app/pages/login.xhtml 第 1 行,第 1 列:^

    My login xhtml以 开始 我正在使用 Java 8 JSF Primefaces Maven Tomcat8 我认为我的配置有问题 例如小服务程序和web xml XML 解析错误 未找到元素位置 行号 1 列 1 就这一点而言
  • “wc”命令的行为是什么?

    例如 myCleanVar wc l lt myFile myDirtVar wc l myFile echo myCleanVar 9 echo myDirtVar 9 myFile 为什么在 myCleanVar 中我从 wc 命令中获
  • git:对“非快进”错误的基本误解

    当我自己工作时 不了解 git 的基础知识还可以 但是现在我正在与另一个人一起工作 并且我们每个人都提交拉取请求以让对方合并它们 这开始成为一个问题 工作流程 我在我的 作者 分支中编写 当准备好进行审查时 我提交一个拉取请求 然后我的编辑
  • pyttsx3初始化错误,无法使用pyttsx3

    我在 pyttsx3 中使用 getproperty voices 属性时遇到一些问题 所以我决定卸载它 然后使用 PIP 重新安装它 看看是否可以解决问题 当我遇到 getproperty voices 错误时的上一个链接 当我尝试访问语