def listen(self): conf_manager = ConfigurationManager() config = conf_manager.instance() detector = hotword_detectors[config['HOTWORD_ENGINE']]( self.detected_callback) detector.listen()
def detected_callback(): logger.info('Hotword detected') player = AudioPlayer() conf_manager = ConfigurationManager() config = conf_manager.instance() player.play(config['DETECT_SOUND']) recorder = Recorder() recorded_file = recorder.record() requester = ProteusRequests() try: answer_audio = requester.speech_audio(recorded_file) except Exception: logger.error('Connection Error: server unreachable') return logger.info('Playing...') player.play(answer_audio)