def deactivate_deprecated(self, message=None): # Deactivate official skill # TODO depending on https://github.com/MycroftAI/skill-speak/issues/24 # code bellow can be removed skills_config = self.config_core.get("skills", {}) blacklisted_skills = skills_config.get("blacklisted_skills", []) config = LocalConf(USER_CONFIG) blacklisted_skills += config.get("skills", {}).get("blacklisted_skills", []) store = False for skill in ["skill-repeat-recent", "mycroft-speak.mycroftai"]: if skill not in blacklisted_skills: self.log.info("Parrot skill blacklisted conflicting skill " + skill) self.bus.emit( Message('skillmanager.deactivate', {"skill": skill})) blacklisted_skills.append(skill) if "skills" not in config: config["skills"] = {} if "blacklisted_skills" not in config["skills"]: config["skills"]["blacklisted_skills"] = [] config["skills"]["blacklisted_skills"] += blacklisted_skills store = True if store: config.store()
def main(ready_hook=on_ready, error_hook=on_error, stopping_hook=on_stopping): # Read the system configuration """Launch one of the available enclosure implementations. This depends on the configured platform and can currently either be mycroft_mark_1 or mycroft_mark_2, if unconfigured a generic enclosure with only the GUI bus will be started. """ # Read the system configuration system_config = LocalConf(SYSTEM_CONFIG) platform = system_config.get("enclosure", {}).get("platform") enclosure = create_enclosure(platform) if enclosure: try: LOG.debug("Enclosure started!") reset_sigint_handler() create_daemon(enclosure.run) ready_hook() wait_for_exit_signal() stopping_hook() except Exception as e: print(e) else: LOG.info("No enclosure available for this hardware, running headless")
def main(): # Read the system configuration system_config = LocalConf(SYSTEM_CONFIG) platform = system_config.get("enclosure", {}).get("platform") if platform == "mycroft_mark_1": LOG.debug("Creating Mark I Enclosure") from mycroft.client.enclosure.mark1 import EnclosureMark1 enclosure = EnclosureMark1() elif platform == "mycroft_mark_2": LOG.debug("Creating Mark II Enclosure") from mycroft.client.enclosure.mark2 import EnclosureMark2 enclosure = EnclosureMark2() else: LOG.debug("Creating generic enclosure, platform='{}'".format(platform)) # TODO: Mechanism to load from elsewhere. E.g. read a script path from # the mycroft.conf, then load/launch that script. from mycroft.client.enclosure.generic import EnclosureGeneric enclosure = EnclosureGeneric() if enclosure: try: LOG.debug("Enclosure started!") enclosure.run() except Exception as e: print(e) finally: sys.exit() else: LOG.debug("No enclosure available for this hardware, running headless")
def __init__(self, key_phrase="hey mycroft", config=None, lang="en-us"): super(PreciseHotword, self).__init__(key_phrase, config, lang) from precise_runner import (PreciseRunner, PreciseEngine, ReadWriteStream) local_conf = LocalConf(USER_CONFIG) if local_conf.get('precise', {}).get('dist_url') == \ 'http://bootstrap.mycroft.ai/artifacts/static/daily/': del local_conf['precise']['dist_url'] local_conf.store() Configuration.updated(None) self.download_complete = True self.show_download_progress = Timer(0, lambda: None) precise_config = Configuration.get()['precise'] precise_exe = self.install_exe(precise_config['dist_url']) self.precise_model = self.install_model( precise_config['model_url'], key_phrase.replace(' ', '-')).replace('.tar.gz', '.pb') self.has_found = False self.stream = ReadWriteStream() def on_activation(): self.has_found = True self.runner = PreciseRunner(PreciseEngine(precise_exe, self.precise_model), stream=self.stream, on_activation=on_activation) self.runner.start()
def main(): # Read the system configuration system_config = LocalConf(SYSTEM_CONFIG) platform = system_config.get("enclosure", {}).get("platform") if platform == "mycroft_mark_1": LOG.debug("Creating Mark I Enclosure") from mycroft.client.enclosure.mark1 import EnclosureMark1 enclosure = EnclosureMark1() elif platform == "mycroft_mark_2": LOG.debug("Creating Mark II Enclosure") from mycroft.client.enclosure.mark2 import EnclosureMark2 enclosure = EnclosureMark2() else: LOG.debug("Creating generic enclosure, platform='{}'".format(platform)) # TODO: Mechanism to load from elsewhere. E.g. read a script path from # the mycroft.conf, then load/launch that script. from mycroft.client.enclosure.generic import EnclosureGeneric enclosure = EnclosureGeneric() if enclosure: try: LOG.debug("Enclosure started!") enclosure.run() except Exception as e: print(e) finally: sys.exit() else: LOG.debug("No enclosure available for this hardware, running headless")
def __init__(self, key_phrase="hey mycroft", config=None, lang="en-us"): super().__init__(key_phrase, config, lang) global install_package from petact import install_package from precise_runner import (PreciseRunner, PreciseEngine, ReadWriteStream) local_conf = LocalConf(USER_CONFIG) if (local_conf.get('precise', {}).get('dist_url') == 'http://bootstrap.mycroft.ai/artifacts/static/daily/'): del local_conf['precise']['dist_url'] local_conf.store() Configuration.updated(None) self.download_complete = True self.show_download_progress = Timer(0, lambda: None) precise_config = Configuration.get()['precise'] precise_exe = self.update_precise(precise_config) local_model = self.config.get('local_model_file') if local_model: self.precise_model = expanduser(local_model) else: self.precise_model = self.install_model( precise_config['model_url'], key_phrase.replace(' ', '-')).replace('.tar.gz', '.pb') self.has_found = False self.stream = ReadWriteStream() def on_activation(): self.has_found = True trigger_level = self.config.get('trigger_level', 3) sensitivity = self.config.get('sensitivity', 0.5) self.runner = PreciseRunner( PreciseEngine(precise_exe, self.precise_model), trigger_level, sensitivity, stream=self.stream, on_activation=on_activation, ) self.runner.start()
def __init__(self, key_phrase="hey mycroft", config=None, lang="en-us"): super(PreciseHotword, self).__init__(key_phrase, config, lang) from precise_runner import ( PreciseRunner, PreciseEngine, ReadWriteStream ) local_conf = LocalConf(USER_CONFIG) if local_conf.get('precise', {}).get('dist_url') == \ 'http://bootstrap.mycroft.ai/artifacts/static/daily/': del local_conf['precise']['dist_url'] local_conf.store() Configuration.updated(None) self.download_complete = True self.show_download_progress = Timer(0, lambda: None) precise_config = Configuration.get()['precise'] precise_exe = self.install_exe(precise_config['dist_url']) local_model = self.config.get('local_model_file') if local_model: self.precise_model = expanduser(local_model) else: self.precise_model = self.install_model( precise_config['model_url'], key_phrase.replace(' ', '-') ).replace('.tar.gz', '.pb') self.has_found = False self.stream = ReadWriteStream() def on_activation(): self.has_found = True self.runner = PreciseRunner( PreciseEngine(precise_exe, self.precise_model), stream=self.stream, on_activation=on_activation ) self.runner.start()
def __init__(self, key_phrase="hey mycroft", config=None, lang="en-us"): super().__init__(key_phrase, config, lang) from precise_runner import ( PreciseRunner, PreciseEngine, ReadWriteStream ) # We need to save to a writeable location, but the key we need # might be stored in a different, unwriteable, location # Make sure we pick the key we need from wherever it's located, # but save to a writeable location only local_conf = LocalConf( join(xdg.BaseDirectory.xdg_config_home, 'mycroft', 'mycroft.conf') ) for conf_dir in xdg.BaseDirectory.load_config_paths('mycroft'): conf = LocalConf(join(conf_dir, 'mycroft.conf')) # If the current config contains the precise key use it, # otherwise continue to the next file if conf.get('precise', None) is not None: local_conf['precise'] = conf.get('precise', None) break # If the key is not found yet, it might still exist on the old # (deprecated) location if local_conf.get('precise', None) is None: local_conf = LocalConf(OLD_USER_CONFIG) if not local_conf.get('precise', {}).get('use_precise', True): raise PreciseUnavailable if (local_conf.get('precise', {}).get('dist_url') == 'http://bootstrap.mycroft.ai/artifacts/static/daily/'): del local_conf['precise']['dist_url'] local_conf.store() Configuration.updated(None) self.download_complete = True self.show_download_progress = Timer(0, lambda: None) precise_config = Configuration.get()['precise'] precise_exe = self.update_precise(precise_config) local_model = self.config.get('local_model_file') if local_model: self.precise_model = expanduser(local_model) else: self.precise_model = self.install_model( precise_config['model_url'], key_phrase.replace(' ', '-') ).replace('.tar.gz', '.pb') self.has_found = False self.stream = ReadWriteStream() def on_activation(): self.has_found = True trigger_level = self.config.get('trigger_level', 3) sensitivity = self.config.get('sensitivity', 0.5) self.runner = PreciseRunner( PreciseEngine(precise_exe, self.precise_model), trigger_level, sensitivity, stream=self.stream, on_activation=on_activation, ) self.runner.start()