0

While creating an assistant and trying to convert audio to speech using pyttsx3, but everytime I run my program, I get the same error "AttributeError: 'super' object has no attribute 'init' sys:1: UninitializedDeallocWarning: leaking an uninitialized object of type NSSpeechDriver".

I have tried to uninstall it, and then use an earlier version, but the outcome was still the same. Is there a solution to this? I have looked at this AttributeError: 'super' object has no attribute 'init' but the solution did not work for me. Is there anything wrong in my code?

import os
import time
import pyaudio
from gtts import gTTS
import speech_recognition as sr
import playsound
import pyttsx3

engine = pyttsx3.init()


lang = 'en'

while True: 
    def recordAudio():
        said = ""
        
        r = sr.Recognizer()
        with sr.Microphone() as source:
            audio = r.listen(source)
            said = r.recognize_google(audio)

            engine.say(said)
            engine.runAndWait()
                 
            
    
    recordAudio()

Error I got

/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pyttsx3/drivers/nsss.py:12: ObjCSuperWarning: Objective-C subclass uses super(), but super is not objc.super
  class NSSpeechDriver(NSObject):
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pyttsx3/__init__.py", line 20, in init
    eng = _activeEngines[driverName]
          ~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/weakref.py", line 136, in __getitem__
    o = self.data[key]()
        ~~~~~~~~~^^^^^
KeyError: None

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/akdas/Desktop/Voice-Activated-Calculator/main.py", line 9, in <module>
    engine = pyttsx3.init()
             ^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pyttsx3/__init__.py", line 22, in init
    eng = Engine(driverName, debug)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pyttsx3/engine.py", line 30, in __init__
    self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AKD2022
  • 1
  • 1

0 Answers0