Skip to content

Instantly share code, notes, and snippets.

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