[Python] pyttsx3 | Issues Initializing on MacOs

Discussão em 'Python' iniciado por Stack, Setembro 29, 2024.

  1. Stack

    Stack Membro Participativo

    I have a question regarding Python's "Text to Speech" module pyttsx3.

    My Goal:

    • Run pyttsx3 to speak a string of text.

    Where I Stand:

    • Installed pyttsx3
    • Wrote the following lines in VS Code:

    import pyttsx3
    engine = pyttsx3.init("nsss")
    engine.say("Hello World")
    engine.runAndWait()


    Where I am Stuck:

    • The code will not properly initialize.

    See Error Message Below:

    Traceback (most recent call last):
    File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site- packages/pyttsx3/__init__.py", line 20, in init
    eng = _activeEngines[driverName]
    ~~~~~~~~~~~~~~^^^^^^^^^^^^
    File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/weakref.py", line 136, in __getitem__
    o = self.data[key]()
    ~~~~~~~~~^^^^^
    KeyError: 'nsss'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "/Users/drewpeterson/Documents/Programming/Python/CS50/speech.py", line 6, in <module>
    engine = pyttsx3.init("nsss")
    ^^^^^^^^^^^^^^^^^^^^
    File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site- packages/pyttsx3/__init__.py", line 22, in init
    eng = Engine(driverName, debug)
    ^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site- packages/pyttsx3/engine.py", line 30, in __init__
    self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyttsx3/driver.py", line 50, in __init__
    self._module = importlib.import_module(name)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "<frozen importlib._bootstrap>", line 1381, in _gcd_import
    File "<frozen importlib._bootstrap>", line 1354, in _find_and_load
    File "<frozen importlib._bootstrap>", line 1325, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 929, in _load_unlocked
    File "<frozen importlib._bootstrap_external>", line 994, in exec_module
    File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
    File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site- packages/pyttsx3/drivers/nsss.py", line 2, in <module>
    from Foundation import *
    File "<frozen importlib._bootstrap>", line 1403, in _handle_fromlist
    File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/objc/_lazyimport.py", line 160, in __getattr__
    value = self.__calc_all()
    ^^^^^^^^^^^^^^^^^
    File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/objc/_lazyimport.py", line 328, in __calc_all
    all_names.update(p.__all__)
    ^^^^^^^^^
    File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/objc/_lazyimport.py", line 160, in __getattr__
    value = self.__calc_all()
    ^^^^^^^^^^^^^^^^^
    File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/objc/_lazyimport.py", line 257, in __calc_all
    objc.loadBundleVariables(self.__bundle, dct, varmap)
    File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/objc/_pythonify.py", line 52, in numberWrapper
    if isinstance(obj, NSDecimalNumber):
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    objc.internal_error: PyObjC: internal error in _type_lookup at Modules/objc/objc- object.m:380: assertion failed: dict && PyDict_Check(dict)

    Continue reading...

Compartilhe esta Página