【问题标题】:Pyttsxx / pyttsx3 error in init function ( no drivers found )初始化函数中的 Pyttsxx / pyttsx3 错误(未找到驱动程序)
【发布时间】:2022-11-12 01:34:31
【问题描述】:

我修复了 pyttsx 的、engine.py 和 driver.py 文件,并在 stackOverflow 的解决方案上提供了一些帮助,但问题仍然存在(我试图运行一个简单的文本到语音程序)

import pyttsx3 
engine = pyttsx3.init()
engine.say("hello there!")
engine.runAndWait()

程序运行并给出一些错误,例如

Traceback (most recent call last):
File "/home/sawood/Documents/test.py", line 2, in <module>
import pyttsx3
File "/home/sawood/.local/lib/python3.10/site-packages/pyttsx3/__init__.py", line 
1, in <module>
from .engine import Engine
File "/home/sawood/.local/lib/python3.10/site-packages/pyttsx3/engine.py", line 1, 
in <module>
from .driver import driver
ImportError: cannot import name 'driver' from 'pyttsx3.driver' 
(/home/sawood/.local/lib/python3.10/site-packages/pyttsx3/driver.py

任何想法在 linux 上发生了什么或应该做什么(EndeavourOS ~ arch) 我有我的大学小项目要提交请帮忙

【问题讨论】:

    标签: python text-to-speech pyttsx pyttsx3


    【解决方案1】:

    我似乎找到了一个潜在的解决方案! 这可能有效,也可能无效,但看起来您的 PyInstaller 站点包已经跳过了一些重要的 pyttsx3 内容。 要解决此问题,您只需转到安装了 Python 的任何位置(通常路径如下所示:“C:Users[Your User]AppDataLocalProgramsPythonPython[Your Version]Libsite-packages”) 从那里您应该能够在文件夹名称“PyInstaller”(不带引号)下找到一个包,然后,您可以进入 hooks 文件夹,并查找一个名为“hook-pyttsx3.py”的文件(再次不带引号) .如果该文件不存在,您将需要以该名称创建一个新的 python 文件,文件内容应如下所示:

    #-----------------------------------------------------------------------------
    # Copyright (c) 2013-2020, PyInstaller Development Team.
    #
    # Distributed under the terms of the GNU General Public License (version 2
    # or later) with exception for distributing the bootloader.
    #
    # The full license is in the file COPYING.txt, distributed with this software.
    #
    # SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception)
    #-----------------------------------------------------------------------------
    
    
    
    
    
    hiddenimports = [
        'pyttsx3.drivers',
        'pyttsx3.drivers.dummy',
        'pyttsx3.drivers.espeak',
        'pyttsx3.drivers.nsss',
        'pyttsx3.drivers.sapi5', ]
    

    如果确实存在 hook-pyttsx3 文件,请确保内容匹配,如果不匹配,则将其替换为该文件。 希望这可以帮助! p.s.这是我发布的第一个 StackOverflow 答案之一,所以如果我的格式有误,请告诉我! 编辑:起初我没有看到你在 Linux 上。这将是 Windows 系统的解决方案(至少我相信会如此),而且我相信 Linux 也会有类似的解决方案,但我不能完全确定,对于给您带来的不便,我深表歉意。希望它有效!

    【讨论】:

      猜你喜欢
      • 2020-10-16
      • 2021-01-19
      • 1970-01-01
      • 2015-09-02
      • 2018-06-24
      • 1970-01-01
      • 1970-01-01
      • 2018-08-12
      • 1970-01-01
      相关资源
      最近更新 更多