本文整理汇总了Python中mycroft.configuration.Configuration.init方法的典型用法代码示例。如果您正苦于以下问题:Python Configuration.init方法的具体用法?Python Configuration.init怎么用?Python Configuration.init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mycroft.configuration.Configuration
的用法示例。
在下文中一共展示了Configuration.init方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from mycroft.configuration import Configuration [as 别名]
# 或者: from mycroft.configuration.Configuration import init [as 别名]
def main():
global ws
# Create PID file, prevent multiple instancesof this service
mycroft.lock.Lock('skills')
# Connect this Skill management process to the websocket
ws = WebsocketClient()
Configuration.init(ws)
ignore_logs = Configuration.get().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 BaseException:
pass
LOG('SKILLS').debug(message)
ws.on('message', _echo)
# Startup will be called after websocket is fully live
ws.once('open', _starting_up)
ws.run_forever()
示例2: main
# 需要导入模块: from mycroft.configuration import Configuration [as 别名]
# 或者: from mycroft.configuration.Configuration import init [as 别名]
def main():
global ws
global loop
global config
lock = PIDLock("voice")
ws = WebsocketClient()
config = Configuration.get()
Configuration.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()
示例3: handle_speak
# 需要导入模块: from mycroft.configuration import Configuration [as 别名]
# 或者: from mycroft.configuration.Configuration import init [as 别名]
def handle_speak(event):
"""
Handle "speak" message
"""
config = Configuration.get()
Configuration.init(bus)
global _last_stop_signal
# Get conversation ID
if event.context and 'ident' in event.context:
ident = event.context['ident']
else:
ident = 'unknown'
start = time.time() # Time of speech request
with lock:
stopwatch = Stopwatch()
stopwatch.start()
utterance = event.data['utterance']
if event.data.get('expect_response', False):
# When expect_response is requested, the listener will be restarted
# at the end of the next bit of spoken audio.
bus.once('recognizer_loop:audio_output_end', _start_listener)
# 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 (config.get('enclosure', {}).get('platform') != "picroft" and
len(re.findall('<[^>]*>', utterance)) == 0):
chunks = re.split(r'(?<!\w\.\w.)(?<![A-Z][a-z]\.)(?<=\.|\;|\?)\s',
utterance)
for chunk in chunks:
# Check if somthing has aborted the speech
if (_last_stop_signal > start or
check_for_signal('buttonPress')):
# Clear any newly queued speech
tts.playback.clear()
break
try:
mute_and_speak(chunk, ident)
except KeyboardInterrupt:
raise
except Exception:
LOG.error('Error in mute_and_speak', exc_info=True)
else:
mute_and_speak(utterance, ident)
stopwatch.stop()
report_timing(ident, 'speech', stopwatch, {'utterance': utterance,
'tts': tts.__class__.__name__})
示例4: __init_client
# 需要导入模块: from mycroft.configuration import Configuration [as 别名]
# 或者: from mycroft.configuration.Configuration import init [as 别名]
def __init_client(self, params):
config = Configuration.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
Configuration.init(self.ws)
示例5: __init__
# 需要导入模块: from mycroft.configuration import Configuration [as 别名]
# 或者: from mycroft.configuration.Configuration import init [as 别名]
def __init__(self):
self.ws = WebsocketClient()
self.ws.on("open", self.on_ws_open)
Configuration.init(self.ws)
self.config = Configuration.get().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()
示例6: main
# 需要导入模块: from mycroft.configuration import Configuration [as 别名]
# 或者: from mycroft.configuration.Configuration import init [as 别名]
def main():
global bus
reset_sigint_handler()
# Create PID file, prevent multiple instancesof this service
mycroft.lock.Lock('skills')
# Connect this Skill management process to the Mycroft Messagebus
bus = WebsocketClient()
Configuration.init(bus)
bus.on('message', create_echo_function('SKILLS'))
# Startup will be called after the connection with the Messagebus is done
bus.once('open', _starting_up)
create_daemon(bus.run_forever)
wait_for_exit_signal()
shutdown()
示例7: __init__
# 需要导入模块: from mycroft.configuration import Configuration [as 别名]
# 或者: from mycroft.configuration.Configuration import init [as 别名]
def __init__(self):
# Establish Enclosure's websocket connection to the messagebus
self.bus = WebsocketClient()
# Load full config
Configuration.init(self.bus)
config = Configuration.get()
self.lang = config['lang']
self.config = config.get("enclosure")
self.global_config = config
# This datastore holds the data associated with the GUI provider. Data
# is stored in Namespaces, so you can have:
# self.datastore["namespace"]["name"] = value
# Typically the namespace is a meaningless identifier, but there is a
# special "SYSTEM" namespace.
self.datastore = {}
# self.loaded is a list, each element consists of a namespace named
# tuple.
# The namespace namedtuple has the properties "name" and "pages"
# The name contains the namespace name as a string and pages is a
# mutable list of loaded pages.
#
# [Namespace name, [List of loaded qml pages]]
# [
# ["SKILL_NAME", ["page1.qml, "page2.qml", ... , "pageN.qml"]
# [...]
# ]
self.loaded = [] # list of lists in order.
self.explicit_move = True # Set to true to send reorder commands
# Listen for new GUI clients to announce themselves on the main bus
self.GUIs = {} # GUIs, either local or remote
self.active_namespaces = []
self.bus.on("mycroft.gui.connected", self.on_gui_client_connected)
self.register_gui_handlers()
# First send any data:
self.bus.on("gui.value.set", self.on_gui_set_value)
self.bus.on("gui.page.show", self.on_gui_show_page)
self.bus.on("gui.page.delete", self.on_gui_delete_page)
self.bus.on("gui.clear.namespace", self.on_gui_delete_namespace)
self.bus.on("gui.event.send", self.on_gui_send_event)
示例8: init
# 需要导入模块: from mycroft.configuration import Configuration [as 别名]
# 或者: from mycroft.configuration.Configuration import init [as 别名]
def init(websocket):
"""
Start speach related handlers
"""
global ws
global tts
global tts_hash
global config
ws = websocket
Configuration.init(ws)
config = Configuration.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')
示例9: main
# 需要导入模块: from mycroft.configuration import Configuration [as 别名]
# 或者: from mycroft.configuration.Configuration import init [as 别名]
def main():
global bus
global loop
global config
reset_sigint_handler()
PIDLock("voice")
bus = WebsocketClient() # Mycroft messagebus, see mycroft.messagebus
Configuration.init(bus)
config = Configuration.get()
# Register handlers on internal RecognizerLoop bus
loop = RecognizerLoop()
loop.on('recognizer_loop:utterance', handle_utterance)
loop.on('recognizer_loop:speech.recognition.unknown', handle_unknown)
loop.on('speak', handle_speak)
loop.on('recognizer_loop:record_begin', handle_record_begin)
loop.on('recognizer_loop:awoken', handle_awoken)
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)
# Register handlers for events on main Mycroft messagebus
bus.on('open', handle_open)
bus.on('complete_intent_failure', handle_complete_intent_failure)
bus.on('recognizer_loop:sleep', handle_sleep)
bus.on('recognizer_loop:wake_up', handle_wake_up)
bus.on('mycroft.mic.mute', handle_mic_mute)
bus.on('mycroft.mic.unmute', handle_mic_unmute)
bus.on('mycroft.mic.get_status', handle_mic_get_status)
bus.on("mycroft.paired", handle_paired)
bus.on('recognizer_loop:audio_output_start', handle_audio_start)
bus.on('recognizer_loop:audio_output_end', handle_audio_end)
bus.on('mycroft.stop', handle_stop)
create_daemon(bus.run_forever)
create_daemon(loop.run)
wait_for_exit_signal()
示例10: handle_speak
# 需要导入模块: from mycroft.configuration import Configuration [as 别名]
# 或者: from mycroft.configuration.Configuration import init [as 别名]
def handle_speak(event):
"""
Handle "speak" message
"""
config = Configuration.get()
Configuration.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)
示例11: init
# 需要导入模块: from mycroft.configuration import Configuration [as 别名]
# 或者: from mycroft.configuration.Configuration import init [as 别名]
def init(messagebus):
""" Start speech related handlers.
Arguments:
messagebus: Connection to the Mycroft messagebus
"""
global bus
global tts
global tts_hash
global config
bus = messagebus
Configuration.init(bus)
config = Configuration.get()
bus.on('mycroft.stop', handle_stop)
bus.on('mycroft.audio.speech.stop', handle_stop)
bus.on('speak', handle_speak)
bus.on('mycroft.mic.listen', _start_listener)
tts = TTSFactory.create()
tts.init(bus)
tts_hash = config.get('tts')
示例12: load_mycroft_config
# 需要导入模块: from mycroft.configuration import Configuration [as 别名]
# 或者: from mycroft.configuration.Configuration import init [as 别名]
def load_mycroft_config(bus):
""" Load the mycroft config and connect it to updates over the messagebus.
"""
Configuration.init(bus)
return Configuration.get()