def trigger_user_turn_off(self): should_respond = False if self.cns.user_turn_active: if not self.cns.vad_ipu_active and not self.cns.asr_active: current_utt = clean_whitespace(self.cns.user.utterance) if current_utt != self.last_current_utterance: self.last_current_utterance = current_utt context = self.cns.memory.get_dialog_text() context.append(current_utt) trp = self.lm_eot(context) self.cns.user.all_trps.append({ "trp": trp, "time": time.time() }) self.last_guess = "trp" if trp >= self.trp_threshold: should_respond = True self.cns.user.trp_at_eot = trp self.cns.user.utterance_at_eot = current_utt self.cns.finalize_user() if self.verbose: print(C.green + f"EOT recognized: {round(trp, 3)}" + C.end) else: if self.verbose: if self.last_guess != "listen": print(C.red + f"listen: {1-round(trp, 3)}" + C.end) self.last_guess = "listen" return should_respond
def get_dialog_text_debug(self): turns = self.get_turns() dialog = [] if len(turns) > 0: utt = str(turns[0].start_time) + turns[0].utterance last_name = turns[0].name for t in turns[1:]: if t.name == last_name: utt = utt + " " + str(t.start_time) + t.utterance else: dialog.append(clean_whitespace(utt)) utt = str(t.start_time) + t.utterance last_name = t.name dialog.append(clean_whitespace(utt)) return dialog
def get_dialog_text(self): turns = self.get_turns() # utt = str(turns[0].start_time) + turns[0].utterance dialog = [] if len(turns) > 0: utt = turns[0].utterance last_name = turns[0].name for t in turns[1:]: if t.utterance == "": continue if t.name == last_name: utt = utt + " " + clean_whitespace(t.utterance) else: dialog.append(clean_whitespace(utt)) # utt = str(t.start_time) + t.utterance utt = clean_whitespace(t.utterance) last_name = t.name dialog.append(clean_whitespace(utt)) return dialog, last_name
def get_dialog_text(all_turns, turn_index): turns = all_turns[:turn_index + 1] # utt = str(turns[0].start_time) + turns[0].utterance dialog = [] if len(turns) > 0: utt = turns[0]["utterance"] last_name = turns[0]["name"] for t in turns[1:]: if t["utterance"] == "": continue if t["name"] == last_name: utt = utt + " " + clean_whitespace(t["utterance"]) else: dialog.append(clean_whitespace(utt)) # utt = str(t.start_time) + t['utterance'] utt = clean_whitespace(t["utterance"]) last_name = t["name"] dialog.append(clean_whitespace(utt)) return dialog
def trigger_user_turn_off(self): should_respond = False if self.cns.user_turn_active and not self.cns.vad_ipu_active: current_utt = clean_whitespace(self.cns.user.prel_utterance) if current_utt != "" and current_utt != self.last_current_utterance: # print("guessing") # update last prediction text self.last_current_utterance = current_utt # get result from prediction model result = self.predict_trp(current_utt) trp = result["p"] # append trp estimate, the current time and duration of prediction print("pred time: ", result["time"]) self.cns.user.all_trps.append({ "trp": trp, "utterance": current_utt, "predictions": result["predictions"], "prediction_time": result["time"], "time": time.time(), }) self.cns.user.pred_time.append(result["time"]) # self.last_guess = "trp" # check if a turn-shift is recognized if trp >= self.trp_threshold: print("pos trp") self.cns.user.trp_at_eot = trp self.cns.user.utterance_at_eot = current_utt # self.t_predicted_user_off = time.time() # print("last_agent_trigger_on: ", self.last_agent_trigger_on) # print("should respond: TRUE") should_respond = True # self.cns.finalize_user() if self.verbose: print(C.green + f"Take turn: {round(trp, 3)}" + C.end) else: print("neg trp") if self.verbose: print(C.green + f"Listen: ", C.red, f"{round(trp, 3)}" + C.end) # self.last_guess = "listen" return should_respond
def finalize(self): super().finalize() self.planned_utterance = clean_whitespace(self.planned_utterance) if self.completion >= 1: self.utterance = self.planned_utterance
def finalize(self): self.utterance = clean_whitespace(self.utterance) self.end_time = time.time()