args = parse_args() if not args["load"] and "corpus" not in args: raise ValueError("Need a corpus for the parser to parse.") bot = Processor() if args["load"]: bot.load_all(args["encoder"], args["decoder"], args["tokenizer"]) else: p = Parser(args["corpus"]) q, a = p.main(args["google"], args["qa_save"]) bot = Processor() bot.main(q, a) if args["model_save"]: bot.save_model(bot.encoder, name="google_enc.h5") bot.save_model(bot.decoder, name="google_dec.h5") bot.save_tokenizer(bot.tokenizer, name="google.token.pickle") if args["tts"]: tts = TTS() stt = STT() while True: inp = stt.speech_to_text() ans = bot.ask_question(inp) print("The bot said: " + ans) tts.text_to_speech(ans) else: inp = input("Input: ") print(bot.ask_question(inp))