This commit is contained in:
gauthiier 2022-03-13 19:24:02 +01:00
parent eaaf419614
commit 843b99a4f7

View File

@ -1,10 +1,10 @@
import argparse, json, sys, time, random, logging, signal import argparse, json, sys, time, random, logging, signal, threading
import utterance.voice import utterance.voice
import utterance.utils import utterance.utils
import utterance.osc import utterance.osc
import examine.metric import examine.metric
UTTERANCE_LEN = 16 UTTERANCE_LEN = 16 #<--------------- these should be in config
NUM_METRIC_GEN = 50 NUM_METRIC_GEN = 50
NUM_SAMPLE_VOICES = 3 NUM_SAMPLE_VOICES = 3
broadcast = None broadcast = None
@ -57,6 +57,24 @@ def broadcast_utterance(v, utterance):
broadcast.command('clear') broadcast.command('clear')
time.sleep(2) time.sleep(2)
def find_candidates(v, uv_vec, voices, results):
logging.info(f"LOOP::finding candidates")
start = time.time()
candidates = random.sample(voices, NUM_SAMPLE_VOICES)
for c in candidates:
if exit:
break
if c == v:
continue
results += utter_n_vectorise_distance(c, NUM_METRIC_GEN, uv_vec)
results.sort(key=lambda t: t[0], reverse=True)
lapse = time.time() - start
logging.info(f"LOOP::done - {lapse} secs")
def signal_terminate(signum, frame): def signal_terminate(signum, frame):
global exit global exit
@ -117,23 +135,14 @@ def main() -> int:
while not exit: while not exit:
results = []
t = threading.Thread(target=find_candidates, args=[v, uv_vec, voices, results])
t.start()
logging.info(f"LOOP::broadcasting {v.name}") logging.info(f"LOOP::broadcasting {v.name}")
broadcast_utterance(v, uv) broadcast_utterance(v, uv)
logging.info(f"LOOP::finding candidates") t.join()
start = time.time()
candidates = random.sample(voices, NUM_SAMPLE_VOICES)
results = []
for c in candidates:
if exit:
break
if c == v:
continue
results += utter_n_vectorise_distance(c, NUM_METRIC_GEN, uv_vec)
results.sort(key=lambda t: t[0], reverse=True)
lapse = time.time() - start
logging.info(f"LOOP::done - {lapse} secs")
# ok here we need to randomise maybe...?! # ok here we need to randomise maybe...?!
# ([d, t, v]) # ([d, t, v])