Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import speech_recognition as sr
- def get_audio():
- r = sr.Recognizer()
- with sr.Microphone() as source:
- r.adjust_for_ambient_noise(source, duration=5)
- print("listening... ")
- audio = r.listen(source)
- said = ""
- try:
- said = r.recognize_google(audio)
- except sr.UnknownValueError:
- print("Google Speech Recognition could not understand audio")
- except sr.RequestError as e:
- print("Could not request results from Google Speech Recognition service; {0}".format(e))
- return said.lower()
- print(get_audio())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement