def main(ready_hook=on_ready, error_hook=on_error, stopping_hook=on_stopping): """ Main function. Run when file is invoked. """ try: reset_sigint_handler() check_for_signal("isSpeaking") bus = MessageBusClient() # Connect to the Mycroft Messagebus Configuration.set_config_update_handlers(bus) speech.init(bus) LOG.info("Starting Audio Services") bus.on('message', create_echo_function('AUDIO', ['mycroft.audio.service'])) # Connect audio service instance to message bus audio = AudioService(bus) except Exception as e: error_hook(e) else: create_daemon(bus.run_forever) if audio.wait_for_load() and len(audio.service) > 0: # If at least one service exists, report ready ready_hook() wait_for_exit_signal() stopping_hook() else: error_hook('No audio services loaded') speech.shutdown() audio.shutdown()
def listener(): rospy.init_node('mycroft_skills') rospy.loginfo(rospy.get_caller_id() + " started") rospy.Subscriber("mycroft/utterance", String, handle_utterance) rospy.Subscriber("mycroft/remove_skill", String, handle_remove_skill) s = rospy.Service('mycroft/register_skill', MycroftService, handle_register_skill) 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) config = Configuration.get() # Set the active lang to match the configured one set_active_lang(config.get('lang', 'en-us')) bus.on('skill.manager.initialised', initialise_response_server) bus.on('message', create_echo_function('SKILLS')) # Startup will be called after the connection with the Messagebus is done bus.once('open', _starting_up) bus.on('skill.converse.request', check_working) create_daemon(bus.run_forever) wait_for_exit_signal() shutdown() rospy.spin()
def echo(): ws = WebsocketClient() def repeat_utterance(message): message.type = 'speak' ws.emit(message) ws.on('message', create_echo_function(None)) ws.on('recognizer_loop:utterance', repeat_utterance) ws.run_forever()
def echo(): message_bus_client = MessageBusClient() def repeat_utterance(message): message.msg_type = 'speak' message_bus_client.emit(message) message_bus_client.on('message', create_echo_function(None)) message_bus_client.on('recognizer_loop:utterance', repeat_utterance) message_bus_client.run_forever()
def _start_message_bus_client(): """Start the bus client daemon and wait for connection.""" bus = MessageBusClient() Configuration.set_config_update_handlers(bus) bus_connected = Event() bus.on('message', create_echo_function('SKILLS')) # Set the bus connected event when connection is established bus.once('open', bus_connected.set) create_daemon(bus.run_forever) # Wait for connection bus_connected.wait() LOG.info('Connected to messagebus') return bus
def connect_bus_events(bus): # 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.mic.listen', handle_mic_listen) 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) bus.on('message', create_echo_function('VOICE'))
def main(): """ Main function. Run when file is invoked. """ reset_sigint_handler() ws = WebsocketClient() Configuration.init(ws) speech.init(ws) LOG.info("Starting Audio Services") ws.on('message', create_echo_function('AUDIO', ['mycroft.audio.service'])) audio = AudioService(ws) # Connect audio service instance to message bus create_daemon(ws.run_forever) wait_for_exit_signal() speech.shutdown() audio.shutdown()
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()
def main(): """ Main function. Run when file is invoked. """ reset_sigint_handler() check_for_signal("isSpeaking") bus = MessageBusClient() # Connect to the Mycroft Messagebus Configuration.set_config_update_handlers(bus) speech.init(bus) LOG.info("Starting Audio Services") bus.on('message', create_echo_function('AUDIO', ['mycroft.audio.service'])) audio = AudioService(bus) # Connect audio service instance to message bus create_daemon(bus.run_forever) wait_for_exit_signal() speech.shutdown() audio.shutdown()
def main(): """ Main function. Run when file is invoked. """ reset_sigint_handler() check_for_signal("isSpeaking") bus = WebsocketClient() # Connect to the Mycroft Messagebus Configuration.init(bus) speech.init(bus) LOG.info("Starting Audio Services") bus.on('message', create_echo_function('AUDIO', ['mycroft.audio.service'])) audio = AudioService(bus) # Connect audio service instance to message bus create_daemon(bus.run_forever) wait_for_exit_signal() speech.shutdown() audio.shutdown()
def main(): global bus global loop global config reset_sigint_handler() PIDLock("voice") bus = MessageBusClient() # Mycroft messagebus, see mycroft.messagebus Configuration.set_config_update_handlers(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.mic.listen', handle_mic_listen) 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) bus.on('message', create_echo_function('VOICE')) create_daemon(bus.run_forever) create_daemon(loop.run) wait_for_exit_signal()
def main(): rospy.init_node('mycroft_tts') rospy.loginfo(rospy.get_caller_id() + " started") rospy.Subscriber("mycroft/speak", String, handle_speak) rospy.Subscriber("mycroft/stop", String, handle_stop) """ Main function. Run when file is invoked. """ global bus reset_sigint_handler() check_for_signal("isSpeaking") bus = WebsocketClient() # Connect to the Mycroft Messagebus Configuration.init(bus) speech.init(bus) LOG.info("Starting Audio Services") bus.on('message', create_echo_function('AUDIO', ['mycroft.audio.service'])) audio = AudioService(bus) # Connect audio service instance to message bus create_daemon(bus.run_forever) wait_for_exit_signal() speech.shutdown() audio.shutdown() # keep node running rospy.spin()