Skip to content

Instantly share code, notes, and snippets.

@Abhayparashar31
Last active December 14, 2020 09:20
Show Gist options
  • Save Abhayparashar31/4a8ab6114135807405a6c0968e0a3302 to your computer and use it in GitHub Desktop.
Save Abhayparashar31/4a8ab6114135807405a6c0968e0a3302 to your computer and use it in GitHub Desktop.
import speech_recognition as sr
def command():
r = sr.Recognizer()
with sr.Microphone() as source:
print("Alexa: Listening...")
audio=r.listen(source)
try:
query = r.recognize_google(audio)
print(f"master:{query}")
return query
except:
print("Try Again")
## print(command()) ## uncomment this to test the function ### Run the code and speak anything and it will printed on the screen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment