Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def start_recording(self):
- self._logger.debug('start_recording')
- self._is_recording = True
- r = sr.Recognizer()
- audios = []
- while(self._is_recording):
- with sr.Microphone() as source:
- print("Speak!")
- audio = r.listen(source)
- audios.append(audio)
- print("Stopped!")
- speechStrings = []
- for audio in audios:
- try:
- speechString = r.recognize_google(audio)
- speechStrings.append(speechString)
- except sr.UnknownValueError:
- print("Failed to understand")
- except sr.RequestError as e:
- print("Failed to request: {}".format(e))
- print(speechStrings)
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement