Skip to content

Instantly share code, notes, and snippets.

@KaushikShresth07
Created June 12, 2021 13:23
Show Gist options
  • Select an option

  • Save KaushikShresth07/ad1ce78a2e10a2c2aed7bff4990dc051 to your computer and use it in GitHub Desktop.

Select an option

Save KaushikShresth07/ad1ce78a2e10a2c2aed7bff4990dc051 to your computer and use it in GitHub Desktop.
import speech_recognition as sr
def Listen():
r = sr.Recognizer()
with sr.Microphone() as source:
print(" ")
print("Listening...")
r.pause_threshold = 1
audio = r.listen(source)
try:
print(" ")
print("Recognizing...")
query = r.recognize_google(audio, language='en-in')
print(f"Your Command : {query}\n")
except:
return "None"
return query.lower()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment