'AttributeError: 'Recognizer' object has no attribute 'recognize_google'

I was trying the Speech Recognition module in Python(V3.7.9) and have been getting the following error:

AttributeError: 'Recognizer' object has no attribute 'recognize_google'

The version I use is: SpeechRecognition-3.8.1

Here is the code I used:

def takeCommand():
        r = sr.Recognizer()
        with sr.Microphone() as source:
            #r.adjust_for_ambient_noise(source, duration=1)
            print("Listening...")
            speak("Listening...")
            audio = r.listen(source)
            
        try:
            print("Recognizing...")
            speak("Recognizing...")
            query = r.recognize_google(audio)
            print(f"Speech was: {query}\n")

and it's not picking up my voice from the microphone. FİXED!

EDIT: this is how i solved the problem: **query= "" **

def takeCommand():
        r = sr.Recognizer()
        with sr.Microphone() as source:
            r.adjust_for_ambient_noise(source, duration=1)
            print("Listening...")
            #speak("Listening...")
            audio = r.listen(source)
            query = ""

But i am getting this error:

recognize_google() got an unexpected keyword argument 'Language'

i try this code but it can't detect my language:

query = r.recognize_google(audio, Language='tr-TR') 


Sources

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

Source: Stack Overflow

Solution Source