|
@@ -24,6 +24,7 @@ recognizer = FilePerSecondRecognizer
|
|
|
|
|
|
|
|
|
def obt_siguiente_trabajo():
|
|
|
+ log.info("Consultando trabajo")
|
|
|
url = 'https://api.fourier.audio/na/calendario/pendiente?id=%s' % (config['device_id'],)
|
|
|
response = requests.get(url)
|
|
|
return response.json()
|
|
@@ -128,10 +129,14 @@ def procesar_siguiente_pila():
|
|
|
def procesar_trabajo(pendiente):
|
|
|
ciudad = pendiente['origen']
|
|
|
estacion = pendiente['estacion']
|
|
|
- segmento = 10
|
|
|
+ confianza = 35
|
|
|
+ segmento = 5
|
|
|
if "segmento" in pendiente:
|
|
|
segmento = int(pendiente["segmento"])
|
|
|
|
|
|
+ if "confianza" in pendiente:
|
|
|
+ confianza = int(pendiente["confianza"])
|
|
|
+
|
|
|
# Descarga de anuncios
|
|
|
log.info("Descargando anuncios")
|
|
|
try:
|
|
@@ -145,7 +150,6 @@ def procesar_trabajo(pendiente):
|
|
|
|
|
|
anuncio = descargar_anuncio(i["ruta"])
|
|
|
if anuncio is not None:
|
|
|
- log.info("Listo %s" % (i['ruta'],))
|
|
|
anuncios.append(anuncio)
|
|
|
|
|
|
except Exception as err:
|
|
@@ -158,16 +162,16 @@ def procesar_trabajo(pendiente):
|
|
|
for i in pendiente["media"]:
|
|
|
archivo = descargar_media(ciudad, estacion, i["ruta"])
|
|
|
if archivo is not None:
|
|
|
- log.info("Listo %s %s %s" % (ciudad, estacion, i['ruta'],))
|
|
|
media.append((archivo, i["fecha"], i["timestamp"]))
|
|
|
|
|
|
except Exception as err:
|
|
|
log.info(err)
|
|
|
|
|
|
+ log.info("Inicia la comparacion, tamaño de segmento %s" % (segmento,))
|
|
|
try:
|
|
|
-
|
|
|
dejavu = None
|
|
|
resultados = {}
|
|
|
+ extras = {}
|
|
|
if len(media) > 0 and len(anuncio) > 0:
|
|
|
dejavu = Dejavu({"database_type": "mem"})
|
|
|
try:
|
|
@@ -184,9 +188,6 @@ def procesar_trabajo(pendiente):
|
|
|
if not "id" in i:
|
|
|
continue
|
|
|
|
|
|
- if i["confidence"] < 35:
|
|
|
- continue
|
|
|
-
|
|
|
obj = i
|
|
|
obj["match_time"] = None
|
|
|
nombre_anuncio = os.path.split(anuncio)[-1]
|
|
@@ -201,6 +202,14 @@ def procesar_trabajo(pendiente):
|
|
|
"desfase_segundos": obj["offset_seconds"]
|
|
|
}
|
|
|
|
|
|
+ if id not in extras:
|
|
|
+ extras[id] = []
|
|
|
+
|
|
|
+ extras[id].append(dict)
|
|
|
+
|
|
|
+ if i["confidence"] < confianza:
|
|
|
+ continue
|
|
|
+
|
|
|
if id in resultados.keys():
|
|
|
resultados[id]["longitud"] += dict["longitud"]
|
|
|
resultados[id]["confianza"] += dict["confianza"]
|
|
@@ -230,6 +239,7 @@ def procesar_trabajo(pendiente):
|
|
|
i['encontrados'].append(obj)
|
|
|
break
|
|
|
|
|
|
+ # log.info(json.dumps(extras))
|
|
|
log.info("[Resultado] %s" % (json.dumps(resultados)))
|
|
|
pendiente["media"] = None
|
|
|
enviar_resultados(pendiente)
|
|
@@ -247,4 +257,4 @@ if __name__ == '__main__':
|
|
|
log.info('Starting ondemand service')
|
|
|
loop.start()
|
|
|
except KeyboardInterrupt:
|
|
|
- log.error('Process killed')
|
|
|
+ log.error('Process killed')
|