当前位置: 首页>>代码示例>>Python>>正文


Python ConfigurationManager.get方法代码示例

本文整理汇总了Python中mycroft.configuration.ConfigurationManager.get方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigurationManager.get方法的具体用法?Python ConfigurationManager.get怎么用?Python ConfigurationManager.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mycroft.configuration.ConfigurationManager的用法示例。


在下文中一共展示了ConfigurationManager.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import get [as 别名]
 def __init__(self, key_phrase="hey mycroft", config=None, lang="en-us"):
     self.lang = str(lang).lower()
     self.key_phrase = str(key_phrase).lower()
     # rough estimate 1 phoneme per 2 chars
     self.num_phonemes = len(key_phrase) / 2 + 1
     if config is None:
         config = ConfigurationManager.get().get("hot_words", {})
         config = config.get(self.key_phrase, {})
     self.config = config
     self.listener_config = ConfigurationManager.get().get("listener", {})
开发者ID:aatchison,项目名称:mycroft-core,代码行数:12,代码来源:hotword_factory.py

示例2: __init__

# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import get [as 别名]
 def __init__(self):
     config_core = ConfigurationManager.get()
     self.lang = str(self.init_language(config_core))
     config_stt = config_core.get("stt", {})
     self.config = config_stt.get(config_stt.get("module"), {})
     self.credential = self.config.get("credential", {})
     self.recognizer = Recognizer()
开发者ID:jasonehines,项目名称:mycroft-core,代码行数:9,代码来源:__init__.py

示例3: create

# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import get [as 别名]
    def create():
        """
        Factory method to create a TTS engine based on configuration.

        The configuration file ``mycroft.conf`` contains a ``tts`` section with
        the name of a TTS module to be read by this method.

        "tts": {
            "module": <engine_name>
        }
        """

        from mycroft.tts.remote_tts import RemoteTTS
        config = ConfigurationManager.get().get('tts', {})
        module = config.get('module', 'mimic')
        lang = config.get(module).get('lang')
        voice = config.get(module).get('voice')
        clazz = TTSFactory.CLASSES.get(module)

        if issubclass(clazz, RemoteTTS):
            url = config.get(module).get('url')
            tts = clazz(lang, voice, url)
        else:
            tts = clazz(lang, voice)

        tts.validator.validate()
        return tts
开发者ID:ChristopherRogers1991,项目名称:mycroft-core,代码行数:29,代码来源:__init__.py

示例4: __init__

# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import get [as 别名]
 def __init__(self, path):
     self.path = path
     config = ConfigurationManager().get()
     config_server = config.get("server")
     self.url = config_server.get("url")
     self.version = config_server.get("version")
     self.identity = IdentityManager.get()
开发者ID:ChristopherRogers1991,项目名称:mycroft-core,代码行数:9,代码来源:__init__.py

示例5: main

# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import get [as 别名]
def main():
    import tornado.options
    lock = Lock("service")
    tornado.options.parse_command_line()

    def reload_hook():
        """ Hook to release lock when autoreload is triggered. """
        lock.delete()

    autoreload.add_reload_hook(reload_hook)

    config = ConfigurationManager.get().get("websocket")

    host = config.get("host")
    port = config.get("port")
    route = config.get("route")
    validate_param(host, "websocket.host")
    validate_param(port, "websocket.port")
    validate_param(route, "websocket.route")

    routes = [
        (route, WebsocketEventHandler)
    ]
    application = web.Application(routes, **settings)
    application.listen(port, host)
    ioloop.IOLoop.instance().start()
开发者ID:aatchison,项目名称:mycroft-core,代码行数:28,代码来源:main.py

示例6: main

# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import get [as 别名]
def main():
    global ws
    global loop
    global config
    lock = PIDLock("voice")
    ws = WebsocketClient()
    config = ConfigurationManager.get()
    ConfigurationManager.init(ws)
    loop = RecognizerLoop()
    loop.on('recognizer_loop:utterance', handle_utterance)
    loop.on('speak', handle_speak)
    loop.on('recognizer_loop:record_begin', handle_record_begin)
    loop.on('recognizer_loop:wakeword', handle_wakeword)
    loop.on('recognizer_loop:record_end', handle_record_end)
    loop.on('recognizer_loop:no_internet', handle_no_internet)
    ws.on('open', handle_open)
    ws.on('complete_intent_failure', handle_complete_intent_failure)
    ws.on('recognizer_loop:sleep', handle_sleep)
    ws.on('recognizer_loop:wake_up', handle_wake_up)
    ws.on('mycroft.mic.mute', handle_mic_mute)
    ws.on('mycroft.mic.unmute', handle_mic_unmute)
    ws.on("mycroft.paired", handle_paired)
    ws.on('recognizer_loop:audio_output_start', handle_audio_start)
    ws.on('recognizer_loop:audio_output_end', handle_audio_end)
    ws.on('mycroft.stop', handle_stop)
    event_thread = Thread(target=connect)
    event_thread.setDaemon(True)
    event_thread.start()

    try:
        loop.run()
    except KeyboardInterrupt, e:
        LOG.exception(e)
        sys.exit()
开发者ID:aatchison,项目名称:mycroft-core,代码行数:36,代码来源:main.py

示例7: __init__

# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import get [as 别名]
    def __init__(self, directory, name):
        super(SkillSettings, self).__init__()
        # when skills try to instantiate settings
        # in __init__, it can erase the settings saved
        # on disk (settings.json). So this prevents that
        # This is set to true in core.py after skill init
        self.allow_overwrite = False

        self.api = DeviceApi()
        self.config = ConfigurationManager.get()
        self.name = name
        self.directory = directory
        # set file paths
        self._settings_path = join(directory, 'settings.json')
        self._meta_path = join(directory, 'settingsmeta.json')
        self.is_alive = True
        self.loaded_hash = hash(str(self))
        self._complete_intialization = False
        self._device_identity = None
        self._api_path = None
        self._user_identity = None
        self.changed_callback = None

        # if settingsmeta exist
        if isfile(self._meta_path):
            self._poll_skill_settings()
开发者ID:Ceda-EI,项目名称:mycroft-core,代码行数:28,代码来源:settings.py

示例8: __init__

# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import get [as 别名]
    def __init__(self, emitter):
        FallbackSkill.__init__(self)
        self.config = ConfigurationManager.get()['padatious']
        intent_cache = expanduser(self.config['intent_cache'])

        try:
            from padatious import IntentContainer
        except ImportError:
            LOG.error('Padatious not installed. Please re-run dev_setup.sh')
            try:
                call(['notify-send', 'Padatious not installed',
                      'Please run build_host_setup and dev_setup again'])
            except OSError:
                pass
            return
        ver = get_distribution('padatious').version
        if ver != PADATIOUS_VERSION:
            LOG.warning('Using Padatious v' + ver + '. Please re-run ' +
                        'dev_setup.sh to install ' + PADATIOUS_VERSION)

        self.container = IntentContainer(intent_cache)

        self.emitter = emitter
        self.emitter.on('padatious:register_intent', self.register_intent)
        self.emitter.on('padatious:register_entity', self.register_entity)
        self.register_fallback(self.handle_fallback, 5)
        self.finished_training_event = Event()

        self.train_delay = self.config['train_delay']
        self.train_time = get_time() + self.train_delay
        self.wait_and_train()
开发者ID:aatchison,项目名称:mycroft-core,代码行数:33,代码来源:padatious_service.py

示例9: main

# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import get [as 别名]
def main():
    global ws
    global config
    ws = WebsocketClient()
    ConfigurationManager.init(ws)
    config = ConfigurationManager.get()
    speech.init(ws)

    # Setup control of pulse audio
    setup_pulseaudio_handlers(config.get('Audio').get('pulseaudio'))

    def echo(message):
        try:
            _message = json.loads(message)
            if 'mycroft.audio.service' not in _message.get('type'):
                return
            message = json.dumps(_message)
        except:
            pass
        LOG.debug(message)

    LOG.info("Staring Audio Services")
    ws.on('message', echo)
    ws.once('open', load_services_callback)
    try:
        ws.run_forever()
    except KeyboardInterrupt, e:
        LOG.exception(e)
        speech.shutdown()
        sys.exit()
开发者ID:aatchison,项目名称:mycroft-core,代码行数:32,代码来源:main.py

示例10: create_hotword

# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import get [as 别名]
 def create_hotword(hotword="hey mycroft", config=None, lang="en-us"):
     LOG.info("creating " + hotword)
     if not config:
         config = ConfigurationManager.get().get("hotwords", {})
     module = config.get(hotword).get("module", "pocketsphinx")
     config = config.get(hotword, {"module": module})
     clazz = HotWordFactory.CLASSES.get(module)
     return clazz(hotword, config, lang=lang)
开发者ID:aatchison,项目名称:mycroft-core,代码行数:10,代码来源:hotword_factory.py

示例11: __init__

# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import get [as 别名]
 def __init__(self, name, emitter=None):
     self.name = name
     self.bind(emitter)
     self.config_core = ConfigurationManager.get()
     self.config = self.config_core.get(name)
     self.dialog_renderer = None
     self.file_system = FileSystemAccess(join('skills', name))
     self.registered_intents = []
     self.log = getLogger(name)
开发者ID:forslund,项目名称:mycroft-core,代码行数:11,代码来源:core.py

示例12: __init__

# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import get [as 别名]
 def __init__(self):
     self.ws = WebsocketClient()
     ConfigurationManager.init(self.ws)
     self.config = ConfigurationManager.get().get("enclosure")
     self.__init_serial()
     self.reader = EnclosureReader(self.serial, self.ws)
     self.writer = EnclosureWriter(self.serial, self.ws)
     self.writer.write("system.version")
     self.ws.on("enclosure.start", self.start)
     self.started = False
     Timer(5, self.stop).start()     # WHY? This at least needs an explaination, this is non-obvious behavior
开发者ID:forslund,项目名称:mycroft-core,代码行数:13,代码来源:__init__.py

示例13: __init_client

# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import get [as 别名]
    def __init_client(self, params):
        config = ConfigurationManager.get().get("websocket")

        if not params.host:
            params.host = config.get('host')
        if not params.port:
            params.port = config.get('port')

        self.ws = WebsocketClient(host=params.host,
                                  port=params.port,
                                  ssl=params.use_ssl)
开发者ID:jasonehines,项目名称:mycroft-core,代码行数:13,代码来源:container.py

示例14: __init_client

# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import get [as 别名]
    def __init_client(self, params):
        config = ConfigurationManager.get().get("websocket")

        if not params.host:
            params.host = config.get('host')
        if not params.port:
            params.port = config.get('port')

        self.ws = WebsocketClient(host=params.host,
                                  port=params.port,
                                  ssl=params.use_ssl)

        # Connect configuration manager to message bus to receive updates
        ConfigurationManager.init(self.ws)
开发者ID:aatchison,项目名称:mycroft-core,代码行数:16,代码来源:container.py

示例15: __init_serial

# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import get [as 别名]
 def __init_serial(self):
     try:
         self.config = ConfigurationManager.get().get("enclosure")
         self.port = self.config.get("port")
         self.rate = int(self.config.get("rate"))
         self.timeout = int(self.config.get("timeout"))
         self.serial = serial.serial_for_url(
             url=self.port, baudrate=self.rate, timeout=self.timeout)
         LOGGER.info(
             "Connected to: " + self.port + " rate: " + str(self.rate) +
             " timeout: " + str(self.timeout))
     except:
         LOGGER.error(
             "It is not possible to connect to serial port: " + self.port)
         raise
开发者ID:bisaysavath,项目名称:mycroft-core,代码行数:17,代码来源:enclosure.py


注:本文中的mycroft.configuration.ConfigurationManager.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。