def fetch_initial_statement(): # generate_speech() is the function in the speech_generation module # recognize_speech() is the function in the speech_recognition module # first_classifier() is the function in the nlu_one module # second_classifier() is the function in the nlu_two module global state_initial, features_dict #generate_speech (" Hello. I'm your shoe shopping assistant. How can i help you", is_final = "False") generate_speech(features_dict, "initial", "True") while (state_initial == False): statement = recognize_speech() first_nlu_dict = first_classifier(statement, state="initial") if (first_nlu_dict["info_initial_response"] != "empty"): features_dict = first_nlu_dict if (features_dict["info_initial_response"] != "empty"): state_initial = True else: generate_speech(features_dict, "initial", first_nlu_dict)
def fetch_final_statement(): # generate_speech() is the function in the speech_generation module # recognize_speech() is the function in the speech recognition module # first_classifier() is the function in the nlu_one module # second_classifier() is the function in the nlu_two module global state_color, state_category, state_cost, state_final, positive_response_list, features_dict generate_speech(features_dict, "final", "True") while (state_final == False): statement = recognize_speech() first_nlu_dict = first_classifier(statement, "final") if (first_nlu_dict["info_final_response"] == "yes"): features_dict["info_final_response"] = first_nlu_dict[ "info_final_response"] state_final = True elif (first_nlu_dict["info_final_response"] == "no"): state_category = False state_color = False state_cost = False features_dict["info_color"] = "empty" features_dict["info_category"] = "empty" features_dict["info_cost"] = "empty" fetch_info_category() fetch_info_color() fetch_info_cost() generate_speech(features_dict, "final", "True") else: generate_speech(features_dict, "final", "True")
def fetch_info_cost(): # generate_speech() is the function in the speech_generation module # recognize_speech() is the function in the speech recognition module # first_classifier() is the function in the nlu_one module # second_classifier() is the function in the nlu_two module global state_cost, cost_list, features_dict if (features_dict["info_cost"] != "empty"): state_cost = True else: generate_speech(features_dict, "cost", "True") while (state_cost == False): statement = recognize_speech() first_nlu_dict = first_classifier(statement, "cost") if (first_nlu_dict["info_cost"] != "empty"): features_dict["info_cost"] = first_nlu_dict["info_cost"] if (features_dict["info_cost"] != "empty"): state_cost = True else: generate_speech(features_dict, "cost", first_nlu_dict)
def fetch_results_from_db(): global features_dict generate_speech(features_dict, "final", "empty")