Skip to content

Instantly share code, notes, and snippets.

@abdul-rehman-2050
Created March 18, 2018 17:58
Show Gist options
  • Save abdul-rehman-2050/bf31d480fab71845dd38ec287b6e3b46 to your computer and use it in GitHub Desktop.
Save abdul-rehman-2050/bf31d480fab71845dd38ec287b6e3b46 to your computer and use it in GitHub Desktop.
import speech_recognition as sr
# obtain audio from the microphone
r = sr.Recognizer()
with sr.Microphone() as source:
print("Say something!")
audio = r.listen(source)
# recognize speech using Sphinx
try:
print("Sphinx thinks you said " + r.recognize_sphinx(audio))
except sr.UnknownValueError:
print("Sphinx could not understand audio")
except sr.RequestError as e:
print("Sphinx error; {0}".format(e))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment