Skip to content

Instantly share code, notes, and snippets.

@pranav1698
Created October 16, 2019 05:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pranav1698/0b70b51fbe8ca42070afbca07e2b6b5c to your computer and use it in GitHub Desktop.
Save pranav1698/0b70b51fbe8ca42070afbca07e2b6b5c to your computer and use it in GitHub Desktop.
Microphone Speech Recognition
import speech_recognition as sr
r=sr.Recognizer()
with sr.Microphone() as source:
r.adjust_for_ambient_noise(source, duration=5)
print("Say")
audio = r.listen(source)
try:
print(r.recognize_sphinx(audio))
except sr.UnknownValueError:
print("error")
except sr.RequestError as e:
print(e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment