0
def take_command():
    r = sr.Recognizer()
    with sr.Microphone() as source: 
        print("\nListening.......")
        audio = r.listen(source)

try:
    query = r.recognize_google(audio,language='en-in')

except:
    print("\nDidn't catch that, please say again :)")

take_command()

*It seems the SpeechRecognation module is not working for me. * I have all dependencies installed. There is no error after executing the code and it do not even prints the strings coded to print. I am unable to understand what is going wrong with me. Can anyone please help me with this.

  • The indentation is correct. – toyota Supra Aug 23 '22 at 11:17
  • Is the input and output defined to match the device / system? – Solar Mike Aug 23 '22 at 11:18
  • Please [edit] the question and make sure the code in the preview matches your actual code. As it is, this is not valid Python code. The indentation is broken. To me it seems like you're running a different Python file, not this one. – Thomas Weller Aug 23 '22 at 11:21
  • @ThomasWeller While posting i had some formatting problems i have edited it. In my VS-code the same code is not at all doing anything, unable to understand why. I also tried giving microphone number to the `speech_recognition.Microphone` class then it is giving me an error named `OSError: [Errno -9998] Invalid number of channels` – Nitesh Chavan Aug 23 '22 at 11:35
  • A [minimal, reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) would be helpful for others to understand your problem better. – bartolo-otrit Aug 23 '22 at 14:19

0 Answers0