def trigger_process(trigger, voice_command): if player.is_playing(): player.stop() # clean up the temp directory if not debug: for some_file in os.listdir(tmp_path): file_path = os.path.join(tmp_path, some_file) try: if os.path.isfile(file_path): os.remove(file_path) except Exception as exp: # pylint: disable=broad-except logger.warning(exp) if event_commands['pre_interaction']: subprocess.Popen(event_commands['pre_interaction'], shell=True, stdout=subprocess.PIPE) force_record = None if trigger.event_type in triggers.types_continuous: force_record = (trigger.continuous_callback, trigger.event_type in triggers.types_vad) ### Assistant Override if not assistant_handler(voice_command): if trigger.voice_confirm: player.play_speech(resources_path + 'alexayes.mp3') audio_stream = capture.silence_listener(force_record=force_record) alexa_speech_recognizer(audio_stream) ### triggers.enable() if event_commands['post_interaction']: subprocess.Popen(event_commands['post_interaction'], shell=True, stdout=subprocess.PIPE)
def trigger_process(trigger): if event_commands['pre_interaction']: subprocess.Popen(event_commands['pre_interaction'], shell=True, stdout=subprocess.PIPE) if player.is_playing(): player.stop() if trigger.voice_confirm: player.play_speech(resources_path + 'alexayes.mp3') # clean up the temp directory if not debug: for some_file in os.listdir(tmp_path): file_path = os.path.join(tmp_path, some_file) try: if os.path.isfile(file_path): os.remove(file_path) except Exception as exp: # pylint: disable=broad-except logger.warning(exp) force_record = None if trigger.event_type in triggers.types_continuous: force_record = (trigger.continuous_callback, trigger.event_type in triggers.types_vad) capture.silence_listener(force_record=force_record) alexa_speech_recognizer() triggers.enable() if event_commands['post_interaction']: subprocess.Popen(event_commands['post_interaction'], shell=True, stdout=subprocess.PIPE)
def setupAlexaService(): if event_commands['startup']: subprocess.Popen(event_commands['startup'], shell=True, stdout=subprocess.PIPE) try: global capture capture = alexapi.capture.Capture(config, tmp_path) except ConfigurationException as exp: logger.critical(exp) sys.exit(1) capture.setup(platform.indicate_recording) triggers.init(config, trigger_callback, capture) triggers.setup() pHandler.setup() platform.setup() for sig in (signal.SIGABRT, signal.SIGILL, signal.SIGINT, signal.SIGSEGV, signal.SIGTERM): signal.signal(sig, cleanup) logger.info("Checking Internet Connection ...") while not internet_on(): time.sleep(1) try: global token token = Token(config['alexa']) if not str(token): raise RuntimeError except (ConfigurationException, RuntimeError): platform.indicate_failure() sys.exit(1) platform_trigger_callback = triggers.triggers['platform'].platform_callback if 'platform' in triggers.triggers else None platform.after_setup(platform_trigger_callback) triggers.enable() platform.indicate_success()
def trigger_process(trigger): if player.is_playing(): player.stop() # clean up the temp directory if not debug: for some_file in os.listdir(tmp_path): file_path = os.path.join(tmp_path, some_file) try: if os.path.isfile(file_path): os.remove(file_path) except Exception as exp: # pylint: disable=broad-except logger.warning(exp) if trigger.__class__.__name__ == 'PlatformTrigger': platform.toggle_microphone_onoff() if platform.is_microphone_on(): triggers.enable() else: trigger.enable() elif not platform.is_microphone_on(): logger.debug('microphone is off, ignoring trigger') triggers.enable() else: if event_commands['pre_interaction']: subprocess.Popen(event_commands['pre_interaction'], shell=True, stdout=subprocess.PIPE) force_record = None if trigger.event_type in triggers.types_continuous: force_record = (trigger.continuous_callback, trigger.event_type in triggers.types_vad) if trigger.voice_confirm: player.play_speech(resources_path + 'alexayes.mp3') audio_stream = capture.silence_listener(force_record=force_record) alexa_speech_recognizer(audio_stream) triggers.enable() if event_commands['post_interaction']: subprocess.Popen(event_commands['post_interaction'], shell=True, stdout=subprocess.PIPE)
for sig in (signal.SIGABRT, signal.SIGILL, signal.SIGINT, signal.SIGSEGV, signal.SIGTERM): signal.signal(sig, cleanup) logger.info("Checking Internet Connection ...") while not internet_on(): time.sleep(1) try: token = Token(config['alexa']) if not str(token): raise RuntimeError except (ConfigurationException, RuntimeError): platform.indicate_failure() sys.exit(1) platform_trigger_callback = triggers.triggers[ 'platform'].platform_callback if 'platform' in triggers.triggers else None platform.after_setup(platform_trigger_callback) triggers.enable() if not silent: player.play_speech(resources_path + "hello.mp3") platform.indicate_success() while True: time.sleep(1)
triggers.setup() pHandler.setup() platform.setup() logger.info("Checking Internet Connection ...") while not internet_on(): time.sleep(1) try: token = Token(config['alexa']) if not str(token): raise RuntimeError except (ConfigurationException, RuntimeError): platform.indicate_failure() sys.exit(1) platform_trigger_callback = triggers.triggers['platform'].platform_callback if 'platform' in triggers.triggers else None platform.after_setup(platform_trigger_callback) triggers.enable() if not silent: player.play_speech(resources_path + "hello.mp3") platform.indicate_success() while True: time.sleep(1)