def __init__(self, *args): _IdleObject.__init__(self) context = GObject.MainContext.default() self.bucket = bucket = Queue.Queue() # NOQA self.hello = None # with SessionBus() as bus: bus = SessionBus() ss = bus.get("org.scarlett", object_path='/org/scarlett/Listener') # NOQA time.sleep(1) ss_failed_signal = bus.subscribe(sender=None, iface="org.scarlett.Listener", signal="SttFailedSignal", object="/org/scarlett/Listener", arg0=None, flags=0, signal_fired=player_cb) ss_rdy_signal = bus.subscribe(sender=None, iface="org.scarlett.Listener", signal="ListenerReadySignal", object="/org/scarlett/Listener", arg0=None, flags=0, signal_fired=player_cb) ss_kw_rec_signal = bus.subscribe(sender=None, iface="org.scarlett.Listener", signal="KeywordRecognizedSignal", object="/org/scarlett/Listener", arg0=None, flags=0, signal_fired=player_cb) ss_cmd_rec_signal = bus.subscribe(sender=None, iface="org.scarlett.Listener", signal="CommandRecognizedSignal", object="/org/scarlett/Listener", arg0=None, flags=0, signal_fired=command_cb) ss_cancel_signal = bus.subscribe(sender=None, iface="org.scarlett.Listener", signal="ListenerCancelSignal", object="/org/scarlett/Listener", arg0=None, flags=0, signal_fired=player_cb) pp.pprint((ss_failed_signal, ss_rdy_signal, ss_kw_rec_signal, ss_cmd_rec_signal, ss_cancel_signal)) logger.debug("ss_failed_signal: {}".format(ss_failed_signal)) logger.debug("ss_rdy_signal: {}".format(ss_rdy_signal)) logger.debug("ss_kw_rec_signal: {}".format(ss_kw_rec_signal)) logger.debug("ss_cmd_rec_signal: {}".format(ss_cmd_rec_signal)) logger.debug("ss_cancel_signal: {}".format(ss_cancel_signal)) ss.emitConnectedToListener('ScarlettTasker') loop.run() # THE ACTUAL THREAD BIT # self.manager = FooThreadManager(3) try: print("ScarlettTasker Thread Started") except Exception: ss_failed_signal.disconnect() ss_rdy_signal.disconnect() ss_kw_rec_signal.disconnect() ss_cmd_rec_signal.disconnect() ss_cancel_signal.disconnect() loop.quit() self.bucket.put(sys.exc_info()) raise
def __init__(self, *args): threading.Thread.__init__(self) _IdleObject.__init__(self) # Gst.init(None) self.running = False self.finished = False self.ready_sem = threading.Semaphore(0) self.queue = queue.Queue(QUEUE_SIZE) # This wil get filled with an exception if opening fails. self.read_exc = None self.dot_exc = None self.cancelled = False self.name = args[0] self.setName("%s" % self.name) self.pipelines_stack = [] self.elements_stack = [] self.gst_bus_stack = [] self._message = 'This is the ScarlettListenerI' self.config = scarlett_config.Config() self.override_parse = '' self.failed = 0 self.kw_found = 0 self.debug = False self.create_dot = True self.terminate = False self.capsfilter_queue_overrun_handler = None # source: https://github.com/ljmljz/xpra/blob/b32f748e0c29cdbfab836b3901c1e318ea142b33/src/xpra/sound/sound_pipeline.py # NOQA self.bus = None self.bus_message_element_handler_id = None self.bus_message_error_handler_id = None self.bus_message_eos_handler_id = None self.bus_message_state_changed_handler_id = None self.pipeline = None self.start_time = 0 self.state = "stopped" self.buffer_count = 0 self.byte_count = 0 # # Thread manager, maximum of 1 since it'll be long running # self.manager = FooThreadManager(1) self._status_ready = " ScarlettListener is ready" self._status_kw_match = " ScarlettListener caught a keyword match" self._status_cmd_match = " ScarlettListener caught a command match" self._status_stt_failed = " ScarlettListener hit Max STT failures" self._status_cmd_start = " ScarlettListener emitting start command" self._status_cmd_fin = " ScarlettListener Emitting Command run finish" self._status_cmd_cancel = " ScarlettListener cancel speech Recognition" if self.debug: # NOTE: For testing puposes, mainly when in public # so you dont have to keep yelling scarlett in front of strangers self.kw_to_find = ['yo', 'hello', 'man', 'children'] else: self.kw_to_find = self.config.get('scarlett', 'keywords') if self.read_exc: # An error occurred before the stream became ready. self.close(True) raise self.read_exc