When I use pywhatkit module in my voice assistant python program then it shows this error

Viewed 20

When I use pywhatkit module in my voice assistant python program then it shows this error. please help me to resolve this error. my program is 100% ready but please resolve this error. when I tried to use my program without pywhatkit then it doesn't shown any error but when i used to start pywhatkit then it shows error.

import speech_recognition as sr
import pyttsx3
import pywhatkit
import datetime
import wikipedia
import pyjokes
import sys

listener = sr.Recognizer()
engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)


def talk(text):
    engine.say(text)
    engine.runAndWait()


def take_command():
    try:
        with sr.Microphone() as source:
            print('listening...')
            voice = listener.listen(source)
            command = listener.recognize_google(voice)
            command = command.lower()
            if 'alexa' in command:
                command = command.replace('alexa', '')
                print(command)
    except:
        pass
    return command


def run_alexa():
    command = take_command()
    print(command)
    if 'play' in command:
        song = command.replace('play', '')
        talk('playing ' + song)
        pywhatkit.playonyt(song)
    elif 'stop' in command:
        talk('Thanks for using me')
        sys.exit()
    else:
        talk('Please say the command again.')


while True:
    run_alexa()

**THIS IS THE ERROR**

Exception ignored on calling ctypes callback function: <function catch_errors <locals>.call_with_this at 0x0000022117350700>
Traceback (most recent call last):
  File "C:\Users\Vivek-Sharma\AppData\Roaming\Python\Python310\site-packages\comtypes\_comobject.py", line 97, in call_with_this
  File "C:\Program Files\Python310\lib\logging\__init__.py", line 1505, in error
  File "C:\Program Files\Python310\lib\logging\__init__.py", line 1734, in is enabled for
TypeError: 'NoneType' object is not callable
0 Answers
Related