def main(ready_hook=on_ready, error_hook=on_error, stopping_hook=on_stopping): """Start the Audio Service and connect to the Message Bus""" LOG.info("Starting Audio Service") try: reset_sigint_handler() check_for_signal("isSpeaking") whitelist = ['mycroft.audio.service'] bus = start_message_bus_client("AUDIO", whitelist=whitelist) callbacks = StatusCallbackMap(on_ready=ready_hook, on_error=error_hook, on_stopping=stopping_hook) status = ProcessStatus('audio', bus, callbacks) speech.init(bus) # Connect audio service instance to message bus audio = AudioService(bus) status.set_started() except Exception as e: status.set_error(e) else: if audio.wait_for_load() and len(audio.service) > 0: # If at least one service exists, report ready status.set_ready() wait_for_exit_signal() status.set_stopping() else: status.set_error('No audio services loaded') speech.shutdown() audio.shutdown()
def main(ready_hook=on_ready, error_hook=on_error, stopping_hook=on_stopping, watchdog=lambda: None): global bus global loop global config try: reset_sigint_handler() PIDLock("voice") config = Configuration.get() bus = start_message_bus_client("VOICE") connect_bus_events(bus) callbacks = StatusCallbackMap(on_ready=ready_hook, on_error=error_hook, on_stopping=stopping_hook) status = ProcessStatus('speech', bus, callbacks) # Register handlers on internal RecognizerLoop bus loop = RecognizerLoop(watchdog) connect_loop_events(loop) create_daemon(loop.run) status.set_started() except Exception as e: error_hook(e) else: status.set_ready() wait_for_exit_signal() status.set_stopping()
def main(alive_hook=on_alive, started_hook=on_started, ready_hook=on_ready, error_hook=on_error, stopping_hook=on_stopping, watchdog=None): reset_sigint_handler() # Create PID file, prevent multiple instances of this service mycroft.lock.Lock('skills') config = Configuration.get() # Set the active lang to match the configured one set_default_lang(config.get('lang', 'en-us')) # Set the default timezone to match the configured one set_default_tz() # Connect this process to the Mycroft message bus bus = start_message_bus_client("SKILLS") _register_intent_services(bus) event_scheduler = EventScheduler(bus) callbacks = StatusCallbackMap(on_started=started_hook, on_alive=alive_hook, on_ready=ready_hook, on_error=error_hook, on_stopping=stopping_hook) status = ProcessStatus('skills', bus, callbacks) SkillApi.connect_bus(bus) skill_manager = _initialize_skill_manager(bus, watchdog) status.set_started() _wait_for_internet_connection() if skill_manager is None: skill_manager = _initialize_skill_manager(bus, watchdog) device_primer = DevicePrimer(bus, config) device_primer.prepare_device() skill_manager.start() while not skill_manager.is_alive(): time.sleep(0.1) status.set_alive() while not skill_manager.is_all_loaded(): time.sleep(0.1) status.set_ready() wait_for_exit_signal() status.set_stopping() shutdown(skill_manager, event_scheduler)
def run(self): """Start the Enclosure after it has been constructed.""" # Allow exceptions to be raised to the Enclosure Service # if they may cause the Service to fail. start_message_bus_client("ENCLOSURE", self.bus)