target_likelihoods[target] = likelihood

    participant = routing_key.rsplit('.', 1)[1]
    data = {
        "participant": participant,
        "dialogue-acts" : da_label_targets
	}
    _mq.publish(exchange=env_exchange_name,
                routing_key=settings["messaging"]["dialogue_acts"] + ".{}".format(participant),
                body=data)

if __name__ == "__main__":
    player_names = set(player["name"] for player in settings["players"])
    print("Player usernames to use during keyword detection: %s", player_names, file=sys.stderr)
    phrase_da_labeller = create_phrase_da_labeller("phrase_da_labels.tsv", player_names)

	# Testing -----------------------------------------------
#	input = "I accuse orange because she has been talking a lot but white is a villager"
#	print("Test input: %s" % input)
#	input_tokens = WHITESPACE_PATTERN.split(input)
#	da_labels = phrase_da_labeller.find_phrase_da_labels(input_tokens)
#	print(da_labels)
#	da_targets = DialogueActTargets(da_labels)
#	print(da_targets)
	# -------------------------------------------------------

    mq = MessageQueue('keyword-dialogue-act-processor')
    mq.bind_queue(exchange='pre-processor', routing_key="{}.*".format(settings['messaging']['asr_watson']), callback=callback)
    print('[*] Waiting for messages. To exit press CTRL+C')
    mq.listen()
Exemplo n.º 2
0

# Procees input data
def callback(_mq, get_shifted_time, routing_key, body):
    print('connected!', body)

    context = zmq.Context()
    s = context.socket(zmq.SUB)
    s.setsockopt_string(zmq.SUBSCRIBE, '')
    s.connect(body.get('address'))

    while True:
        data = s.recv()
        msgdata, timestamp = msgpack.unpackb(data, use_list=False)
        print(msgdata)
        cv2.imshow('frame', np.array(msgdata))
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break

        #ch.basic_publish(exchange='pre-processor', routing_key='asr_incremental.data.{}'.format(participant), body=data)
    s.close()


mq = MessageQueue('facial-features-preprocessor')
mq.bind_queue(exchange='sensors',
              routing_key='video.new_sensor.*',
              callback=callback)

print('[*] Waiting for messages. To exit press CTRL+C')
mq.listen()
def callback(_mq, get_shifted_time, routing_key, body):
    splitted_key = routing_key.split('.')
    if len(splitted_key) > 1:
        if routing_key.split('.')[1] == 'new_sensor':
            # save the routing key into the dict, e.g. microphone.new_sensor.blue
            connections[routing_key] = body
    else:
        if routing_key.split('.')[
                1] == 'disconnected_sensor' and connections.get(routing_key):
            del connections[routing_key.replace('disconnected_sensor',
                                                'new_sensor')]


mq.bind_queue(exchange='sensors',
              routing_key="*.new_sensor.*",
              callback=callback)
mq.bind_queue(exchange='sensors',
              routing_key="*.disconnected_sensor.*",
              callback=callback)


def zmq_connection(_mq):
    context = zmq.Context()
    s = context.socket(zmq.REP)
    s.bind('tcp://*:45322')
    while True:
        message = s.recv_string()
        s.send(b'')
        for routing_key, body in connections.items():
            if str(message) in routing_key:
Exemplo n.º 4
0
                data = q.get()
                f.write(data)
                print('{} writes left to do..', q.qsize())
        print('writer closed'.format(log_file))

    _thread = Thread(target=run, args=(log_file, ))
    _thread.deamon = True
    _thread.start()

    thread = Thread(target=storage_writer, args=(log_file, ))
    thread.deamon = True
    thread.start()


mq = MessageQueue('logger')
mq.bind_queue(exchange='sensors',
              routing_key=listen_to_routing_key,
              callback=callback)

resend_new_sensor_messages.resend_new_sensor_messages()
print('[*] Waiting for messages. To exit press CTRL-C')
try:
    mq.listen()
finally:
    global_runner = False
    for sock in sockets:
        print(sock.closed)
        if not sock.closed:
            sock.close()
    mq.stop()
settings = yaml.safe_load(open(SETTINGS_FILE, 'r').read())


session_name = datetime.datetime.now().isoformat().replace('.', '_').replace(':', '_')

log_path = os.path.join(settings['logging']['asr_path'], session_name)

os.mkdir(log_path)


# Procees input data
def callback(ch, method, properties, body):
    # participant = routing_key.rsplit('.', 1)[1]
    path = os.path.join(log_path, '{}.txt'.format(method.routing_key))
    with open(path, 'ab') as f:
        f.write(msgpack.packb((method.exchange, method.routing_key, body)))
    print(method.exchange, method.routing_key, body)
    print("-------------------------------------------------")

mq = MessageQueue('asr-logger')

mq.bind_queue(exchange=settings['messaging']['pre_processing'], routing_key="*.*.*", callback_wrapper_func=callback)
mq.bind_queue(exchange=settings['messaging']['sensors'], routing_key="*.*.*", callback_wrapper_func=callback)
mq.bind_queue(exchange=settings['messaging']['wizard'], routing_key="*.*.*", callback_wrapper_func=callback)
mq.bind_queue(exchange=settings['messaging']['environment'], routing_key="*.*.*", callback_wrapper_func=callback)
mq.bind_queue(exchange=settings['messaging']['fatima'], routing_key="*.*.*", callback_wrapper_func=callback)


print('[*] Waiting for messages. To exit press CTRL+C')
mq.listen()
        """
		Sets or resets features to zero, used after processing of sequence.
		"""
        self.blink = 0
        self.mouth_open = 0
        self.inner_brow_raise = 0
        self.outer_brow_raise = 0
        # TODO: Add highlevel features


participants = defaultdict(FaceProcessor)


def callback(_mq, get_shifted_time, routing_key, body):
    participant = routing_key.rsplit('.', 1)[1]
    data = participants[participant].collect_frame(body)
    if data:
        data["timestamps"] = body["timestamps"]
        _mq.publish(exchange=settings["messaging"]["environment"],
                    routing_key='faceprocessor.{}'.format(participant),
                    body=data)


mq = MessageQueue('face_processor')
mq.bind_queue(exchange=settings["messaging"]["pre_processing"],
              routing_key='openface.data.*',
              callback=callback)

print('[*] Waiting for messages. To exit press CTRL+C')
mq.listen()
                }

                key = settings['messaging']['tobii_processing']
                new_routing_key = "{key}.{participant}".format(
                    key=key, participant=pname)
                _mq.publish(exchange='pre-processor',
                            routing_key=new_routing_key,
                            body=json_data)

                return

            # Send for every participant
            sendjson(pname)
        s.close()

    participant = routing_key.rsplit('.', 1)[1]
    thread = Thread(target=run, args=(participant, _mq))
    thread.deamon = True
    thread.start()


mq = MessageQueue('tobii-preprocessor')

mq.bind_queue(exchange='sensors',
              routing_key="{}.*".format(
                  settings['messaging']['new_sensor_tobii']),
              callback=callback)

print('[*] Waiting for messages. To exit press CTRL+C')
mq.listen()
                'confidence':
                msg['results'][0].get('alternatives',
                                      [{}])[0].get('confidence')
            }
            if msg["results"][0]["final"]:
                self.timer = None
            self.on_message_callback(data)


def callback(_mq, get_shifted_time, routing_key, body):
    participant = routing_key.rsplit('.', 1)[1]
    print('connected {}'.format(routing_key))

    def on_message(data):
        if DEBUG: print(data)
        routing_key = 'asr.data' if data["final"] else 'asr.incremental_data'
        _mq.publish(exchange='pre-processor',
                    routing_key='{}.{}'.format(routing_key, participant),
                    body=data)

    WatsonASR(body.get('address'), recognition_method_url, token, on_message)


mq = MessageQueue('watson-asr-preprocessor')
mq.bind_queue(exchange='sensors',
              routing_key='microphone.new_sensor.*',
              callback=callback)

print('[*] Waiting for messages. To exit press CTRL+C')
mq.listen()
                        "glove_left": {},
                        "glove_right": {}
                    }

                    key = settings['messaging']['mocap_processing']
                    new_routing_key = "{key}.{participant}".format(
                        key=key, participant=participantname)
                    _mq.publish(exchange='pre-processor',
                                routing_key=new_routing_key,
                                body=json_data)

                    return

                # Send for every participant
                sendjson('white')
                sendjson('pink')
                sendjson('blue')
                sendjson('orange')
                sendjson('brown')
                sendjson('black')
    s.close()


mq = MessageQueue('mocap-preprocessor')
mq.bind_queue(exchange='sensors',
              routing_key=settings['messaging']['new_sensor_mocap'],
              callback=callback)

print('[*] Waiting for messages. To exit press CTRL+C')
mq.listen()