本文整理汇总了Python中mycroft.configuration.ConfigurationManager.instance方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigurationManager.instance方法的具体用法?Python ConfigurationManager.instance怎么用?Python ConfigurationManager.instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mycroft.configuration.ConfigurationManager
的用法示例。
在下文中一共展示了ConfigurationManager.instance方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import instance [as 别名]
def __init__(self, wake_word_recognizer):
self.config = ConfigurationManager.instance()
listener_config = self.config.get('listener')
self.upload_config = listener_config.get('wake_word_upload')
self.wake_word_name = listener_config['wake_word']
# The maximum audio in seconds to keep for transcribing a phrase
# The wake word must fit in this time
num_phonemes = wake_word_recognizer.num_phonemes
len_phoneme = listener_config.get('phoneme_duration', 120) / 1000.0
self.TEST_WW_SEC = int(num_phonemes * len_phoneme)
self.SAVED_WW_SEC = (10 if self.upload_config['enable']
else self.TEST_WW_SEC)
speech_recognition.Recognizer.__init__(self)
self.wake_word_recognizer = wake_word_recognizer
self.audio = pyaudio.PyAudio()
self.multiplier = listener_config.get('multiplier')
self.energy_ratio = listener_config.get('energy_ratio')
# check the config for the flag to save wake words.
self.save_utterances = listener_config.get('record_utterances', False)
self.save_wake_words = listener_config.get('record_wake_words') \
or self.upload_config['enable'] or self.config['opt_in']
self.upload_lock = Lock()
self.save_wake_words_dir = join(gettempdir(), 'mycroft_wake_words')
self.filenames_to_upload = []
self.mic_level_file = os.path.join(get_ipc_directory(), "mic_level")
self._stop_signaled = False
示例2: get
# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import instance [as 别名]
def get(phrase, lang=None, context=None):
"""
Looks up a resource file for the given phrase. If no file
is found, the requested phrase is returned as the string.
This will use the default language for translations.
Args:
phrase (str): resource phrase to retrieve/translate
lang (str): the language to use
context (dict): values to be inserted into the string
Returns:
str: a randomized and/or translated version of the phrase
"""
if not lang:
from mycroft.configuration import ConfigurationManager
lang = ConfigurationManager.instance().get("lang")
filename = "text/"+lang.lower()+"/"+phrase+".dialog"
template = resolve_resource_file(filename)
if not template:
logger.debug("Resource file not found: " + filename)
return phrase
stache = MustacheDialogRenderer()
stache.load_template_file("template", template)
if not context:
context = {}
return stache.render("template", context)
示例3: main
# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import instance [as 别名]
def main():
global ws
lock = Lock('skills') # prevent multiple instances of this service
# Connect this Skill management process to the websocket
ws = WebsocketClient()
ConfigurationManager.init(ws)
ignore_logs = ConfigurationManager.instance().get("ignore_logs")
# Listen for messages and echo them for logging
def _echo(message):
try:
_message = json.loads(message)
if _message.get("type") in ignore_logs:
return
if _message.get("type") == "registration":
# do not log tokens from registration messages
_message["data"]["token"] = None
message = json.dumps(_message)
except:
pass
logger.debug(message)
ws.on('message', _echo)
# Startup will be called after websocket is full live
ws.once('open', _starting_up)
ws.run_forever()
示例4: __init__
# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import instance [as 别名]
def __init__(self):
self.ws = WebsocketClient()
self.ws.on("open", self.on_ws_open)
ConfigurationManager.init(self.ws)
self.config = ConfigurationManager.instance().get("enclosure")
self.__init_serial()
self.reader = EnclosureReader(self.serial, self.ws)
self.writer = EnclosureWriter(self.serial, self.ws)
# initiates the web sockets on display manager
# NOTE: this is a temporary place to initiate display manager sockets
initiate_display_manager_ws()
示例5: __init__
# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import instance [as 别名]
def __init__(self):
self.ws = WebsocketClient()
ConfigurationManager.init(self.ws)
self.config = ConfigurationManager.instance().get("enclosure")
self.__init_serial()
self.reader = EnclosureReader(self.serial, self.ws)
self.writer = EnclosureWriter(self.serial, self.ws)
# Send a message to the Arduino across the serial line asking
# for a reply with version info.
self.writer.write("system.version")
# When the Arduino responds, it will generate this message
self.ws.on("enclosure.started", self.on_arduino_responded)
self.arduino_responded = False
# Start a 5 second timer. If the serial port hasn't received
# any acknowledgement of the "system.version" within those
# 5 seconds, assume there is nothing on the other end (e.g.
# we aren't running a Mark 1 with an Arduino)
Timer(5, self.check_for_response).start()
# Notifications from mycroft-core
self.ws.on("enclosure.notify.no_internet", self.on_no_internet)
示例6: import
# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import instance [as 别名]
from speech_recognition import (
Microphone,
AudioSource,
AudioData
)
from mycroft.configuration import ConfigurationManager
from mycroft.util import (
check_for_signal,
get_ipc_directory,
resolve_resource_file,
play_wav
)
from mycroft.util.log import getLogger
config = ConfigurationManager.instance()
listener_config = config.get('listener')
logger = getLogger(__name__)
__author__ = 'seanfitz'
class MutableStream(object):
def __init__(self, wrapped_stream, format, muted=False):
assert wrapped_stream is not None
self.wrapped_stream = wrapped_stream
self.muted = muted
self.SAMPLE_WIDTH = pyaudio.get_sample_size(format)
self.muted_buffer = b''.join([b'\x00' * self.SAMPLE_WIDTH])
def mute(self):
示例7: getLogger
# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import instance [as 别名]
from mycroft.util.log import getLogger
from mycroft.api import is_paired
import mycroft.dialog
logger = getLogger("Skills")
__author__ = 'seanfitz'
ws = None
loaded_skills = {}
last_modified_skill = 0
skills_directories = []
skill_reload_thread = None
skills_manager_timer = None
installer_config = ConfigurationManager.instance().get("SkillInstallerSkill")
MSM_BIN = installer_config.get("path", join(MYCROFT_ROOT_PATH, 'msm', 'msm'))
def connect():
global ws
ws.run_forever()
def install_default_skills(speak=True):
"""
Install default skill set using msm.
Args:
speak (optional): Enable response for success. Default True
"""
示例8: load_vocab_from_file
# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import instance [as 别名]
from os.path import join, dirname, splitext, isdir
from functools import wraps
from adapt.intent import Intent
from mycroft.client.enclosure.api import EnclosureAPI
from mycroft.configuration import ConfigurationManager
from mycroft.dialog import DialogLoader
from mycroft.filesystem import FileSystemAccess
from mycroft.messagebus.message import Message
from mycroft.util.log import getLogger
from mycroft.skills.settings import SkillSettings
__author__ = 'seanfitz'
skills_config = ConfigurationManager.instance().get("skills")
BLACKLISTED_SKILLS = skills_config.get("blacklisted_skills", [])
SKILLS_DIR = "/opt/mycroft/skills"
MainModule = '__init__'
logger = getLogger(__name__)
def load_vocab_from_file(path, vocab_type, emitter):
if path.endswith('.voc'):
with open(path, 'r') as voc_file:
for line in voc_file.readlines():
parts = line.strip().split("|")
entity = parts[0]
示例9: connect
# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import instance [as 别名]
from mycroft.messagebus.client.ws import WebsocketClient
from mycroft.messagebus.message import Message
from mycroft.skills.core import load_skill, create_skill_descriptor, \
MainModule, FallbackSkill
from mycroft.skills.event_scheduler import EventScheduler
from mycroft.skills.intent_service import IntentService
from mycroft.skills.padatious_service import PadatiousService
from mycroft.util import connected
from mycroft.util.log import LOG
ws = None
event_scheduler = None
skill_manager = None
skills_config = ConfigurationManager.instance().get("skills")
BLACKLISTED_SKILLS = skills_config.get("blacklisted_skills", [])
PRIORITY_SKILLS = skills_config.get("priority_skills", [])
SKILLS_DIR = '/opt/mycroft/skills'
MSM_BIN = ConfigurationManager.instance().get("SkillInstallerSkill").get(
"path", join(MYCROFT_ROOT_PATH, 'msm', 'msm'))
MINUTES = 60 # number of seconds in a minute (syntatic sugar)
def connect():
global ws
ws.run_forever()
def _starting_up():
"""