Advertisement
katkid

Speech.py

Jul 3rd, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. import speech_recognition as sr
  2.  
  3. r = sr.Recognizer()
  4. mic = sr.Microphone()
  5.  
  6. with mic as source:
  7.     r.adjust_for_ambient_noise(source)
  8.     while True:
  9.         audio = r.listen(source)
  10.  
  11.         try:
  12.             resp = r.recognize_google(audio, language='vi-VN')
  13.             print(resp)
  14.         except sr.UnknownValueError:
  15.             print("loi...")
  16.         except sr.RequestError as e:
  17.             print(e)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement