Ejemplo n.º 1
0
 def create(module=None):
     module = module or "amazon"
     config = get_neon_lang_config()
     module = module or config.get("translation_module", "google")
     # TODO: Check file locations DM
     if module == "amazon" \
             and get_neon_tts_config()["amazon"].get("aws_access_key_id", "") == "":
         from neon_utils.authentication_utils import find_neon_aws_keys, populate_amazon_keys_config
         try:
             config_keys = find_neon_aws_keys()
             populate_amazon_keys_config(config_keys)
         except FileNotFoundError:
             LOG.debug("Amazon credentials not available")
             module = "google"
         except Exception as e:
             LOG.error(e)
             module = "google"
     try:
         clazz = TranslatorFactory.CLASSES.get(module)
         return clazz()
     except Exception as e:
         # The translate backend failed to start. Report it and fall back to
         # default.
         LOG.exception(
             'The selected translator backend could not be loaded, '
             'falling back to default...')
         LOG.error(e)
         if module != 'google':
             return GoogleTranslator()
         else:
             raise
Ejemplo n.º 2
0
    def __init__(self, name=None, bus=None, use_settings=True):
        self.user_config = get_neon_user_config()
        self.local_config = get_neon_local_config()

        self._ngi_settings: Optional[NGIConfig] = None

        super(NeonSkill, self).__init__(name, bus, use_settings)
        self.cache_loc = os.path.expanduser(self.local_config.get('dirVars', {}).get('cacheDir') or
                                            "~/.local/share/neon/cache")
        self.lru_cache = LRUCache()

        # TODO: Depreciate these references, signal use is discouraged DM
        self.create_signal = create_signal
        self.check_for_signal = check_for_signal

        self.sys_tz = gettz()
        self.gui_enabled = self.local_config.get("prefFlags", {}).get("guiEvents", False)

        # if use_settings:
        #     self.settings = {}
        #     self._initial_settings = None
        #     self.init_settings()
        # else:
        #     LOG.error(f"{name} Skill requested no settings!")
        #     self.settings = None

        self.scheduled_repeats = []

        # Server-specific imports and timeout setting
        # A server is a device that hosts the core and skills to serve clients,
        # but that a user will not interact with directly.
        # A server will likely serve multiple users and devices concurrently.
        if self.local_config.get("devVars", {}).get("devType", "generic") == "server":
            self.server = True
            self.default_intent_timeout = 90
        else:
            self.server = False
            self.default_intent_timeout = 60

        self.neon_core = True  # TODO: This should be depreciated DM
        self.actions_to_confirm = dict()

        self.skill_mode = self.user_config.content.get('response_mode', {}).get('speed_mode') or DEFAULT_SPEED_MODE
        self.extension_time = SPEED_MODE_EXTENSION_TIME.get(self.skill_mode)

        try:
            # Lang support
            self.language_config = get_neon_lang_config()
            self.lang_detector = DetectorFactory.create()  # Default fastlang
            self.translator = TranslatorFactory.create()  # Default Amazon
        except Exception as e:
            LOG.error(e)
            self.language_config, self.language_detector, self.translator = None, None, None
Ejemplo n.º 3
0
 def create(module=None):
     module = module or "fastlang"
     config = get_neon_lang_config()
     module = module or config.get("detection_module", "fastlang")
     try:
         clazz = DetectorFactory.CLASSES.get(module)
         return clazz()
     except Exception as e:
         # The translate backend failed to start. Report it and fall back to
         # default.
         LOG.exception(
             'The selected language detector backend could not be loaded, '
             'falling back to default...')
         LOG.error(e)
         if module != 'fastlang':
             return FastLangDetector()
         else:
             raise
Ejemplo n.º 4
0
 def __init__(self):
     self.config = get_neon_lang_config()
     self.boost = self.config["boost"]
     self.default_language = self.config["user"].split("-")[0]
     self.internal_language = self.config["internal"]
Ejemplo n.º 5
0
 def __init__(self):
     self.config = get_neon_lang_config()
     self.default_language = self.config["user"].split("-")[0]
     # hint_language: str  E.g., 'ITALIAN' or 'it' boosts Italian
     self.hint_language = self.config["user"].split("-")[0]
     self.boost = self.config.get("boost")