本文整理汇总了Python中mycroft.configuration.ConfigurationManager.init方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigurationManager.init方法的具体用法?Python ConfigurationManager.init怎么用?Python ConfigurationManager.init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mycroft.configuration.ConfigurationManager
的用法示例。
在下文中一共展示了ConfigurationManager.init方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import init [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()
示例2: main
# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import init [as 别名]
def main():
global ws
global loop
ws = WebsocketClient()
tts.init(ws)
ConfigurationManager.init(ws)
loop = RecognizerLoop()
loop.on('recognizer_loop:utterance', handle_utterance)
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('speak', handle_speak)
ws.on('open', handle_open)
ws.on('speak', handle_speak)
ws.on(
'multi_utterance_intent_failure',
handle_multi_utterance_intent_failure)
ws.on('recognizer_loop:sleep', handle_sleep)
ws.on('recognizer_loop:wake_up', handle_wake_up)
ws.on('mycroft.stop', handle_stop)
ws.on("mycroft.paired", handle_paired)
event_thread = Thread(target=connect)
event_thread.setDaemon(True)
event_thread.start()
try:
loop.run()
except KeyboardInterrupt, e:
logger.exception(e)
event_thread.exit()
sys.exit()
示例3: main
# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import init [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()
示例4: main
# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import init [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()
示例5: __init__
# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import init [as 别名]
def __init__(self):
self.iface = pyw.winterfaces()[0]
self.ap = AccessPoint(self.iface)
self.server = None
self.ws = WebsocketClient()
ConfigurationManager.init(self.ws)
self.enclosure = EnclosureAPI(self.ws)
self.init_events()
self.conn_monitor = None
self.conn_monitor_stop = threading.Event()
示例6: __init__
# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import init [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
示例7: __init__
# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import init [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()
示例8: __init_client
# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import init [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)
示例9: init
# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import init [as 别名]
def init(websocket):
"""
Start speach related handlers
"""
global ws
global tts
global tts_hash
global config
ws = websocket
ConfigurationManager.init(ws)
config = ConfigurationManager.get()
ws.on('mycroft.stop', handle_stop)
ws.on('mycroft.audio.speech.stop', handle_stop)
ws.on('speak', handle_speak)
tts = TTSFactory.create()
tts.init(ws)
tts_hash = config.get('tts')
示例10: main
# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import init [as 别名]
def main():
global ws
ws = WebsocketClient()
ConfigurationManager.init(ws)
def echo(message):
try:
_message = json.loads(message)
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)
ws.once('open', load_skills_callback)
ws.run_forever()
示例11: main
# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import init [as 别名]
def main():
global ws
global loop
global config
global tts
global tts_hash
lock = PIDLock("voice")
ws = WebsocketClient()
config = ConfigurationManager.get()
tts = TTSFactory.create()
tts.init(ws)
tts_hash = config.get('tts')
ConfigurationManager.init(ws)
loop = RecognizerLoop()
loop.on('recognizer_loop:utterance', handle_utterance)
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('speak', handle_speak)
loop.on('recognizer_loop:no_internet', handle_no_internet)
ws.on('open', handle_open)
ws.on('speak', handle_speak)
ws.on(
'multi_utterance_intent_failure',
handle_multi_utterance_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.stop', handle_stop)
ws.on("mycroft.paired", handle_paired)
event_thread = Thread(target=connect)
event_thread.setDaemon(True)
event_thread.start()
try:
loop.run()
except KeyboardInterrupt, e:
logger.exception(e)
event_thread.exit()
sys.exit()
示例12: handle_speak
# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import init [as 别名]
def handle_speak(event):
"""
Handle "speak" message
"""
config = ConfigurationManager.get()
ConfigurationManager.init(ws)
global _last_stop_signal
# Mild abuse of the signal system to allow other processes to detect
# when TTS is happening. See mycroft.util.is_speaking()
utterance = event.data['utterance']
if event.data.get('expect_response', False):
ws.once('recognizer_loop:audio_output_end', _trigger_expect_response)
# This is a bit of a hack for Picroft. The analog audio on a Pi blocks
# for 30 seconds fairly often, so we don't want to break on periods
# (decreasing the chance of encountering the block). But we will
# keep the split for non-Picroft installs since it give user feedback
# faster on longer phrases.
#
# TODO: Remove or make an option? This is really a hack, anyway,
# so we likely will want to get rid of this when not running on Mimic
if not config.get('enclosure', {}).get('platform') == "picroft":
start = time.time()
chunks = re.split(r'(?<!\w\.\w.)(?<![A-Z][a-z]\.)(?<=\.|\?)\s',
utterance)
for chunk in chunks:
try:
mute_and_speak(chunk)
except KeyboardInterrupt:
raise
except:
LOG.error('Error in mute_and_speak', exc_info=True)
if _last_stop_signal > start or check_for_signal('buttonPress'):
break
else:
mute_and_speak(utterance)
示例13: __init__
# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import init [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)