'Unable to run program with both speech recognizer and pywhatkit (both run individually, pywhatkit runs only when given text command)

import pyttsx3
import speech_recognition as sr
import webbrowser
import pywhatkit
engine=pyttsx3.init('sapi5')
voices=engine.getProperty('voices')
engine.setProperty('voice',voices[0].id)
def speak(audio):
     engine.say(audio)
    engine.runAndWait()
def takeCommand():
    r=sr.Recognizer()
    with sr.Microphone() as source:
        print("Listening")
        r.pause_threshold=1
        r.energy_threshold=500
        audio=r.listen(source)
    try:
        print("Recognising what you said...")
        query1=r.recognize_google(audio, language="en-in")
        print(query1)
    except Exception as e:
        speak("Didn't get you sir...")
        return "NONE"
    return query1
if __name__=="__main__":
    speak("Your command sir...")
    query=takeCommand()
    query1=str(query).lower()
    if 'search on google' in query:
        speak("Connected to google sir,What to search")
        query2=takeCommand()
        pywhatkit.search(query2)

This is the code that i am running on VS Code Output: Listening Recognising what you said... search on Google Exception ignored on calling ctypes callback function: <function catch_errors..call_with_this at 0x0000021274A041F0> Traceback (most recent call last): File "C:\Pyhton 10\lib\site-packages\comtypes_comobject.py", line 91, in call_with_this File "C:\Pyhton 10\lib\logging_init_.py", line 1505, in error File "C:\Pyhton 10\lib\logging_init_.py", line 1734, in isEnabledFor TypeError: 'NoneType' object is not callable



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source