def main(): defaultConfig = { 'url': 'https://gateway.watsonplatform.net/dialog/api', 'user': '******', 'password': '******', } home = os.path.expanduser("~") defaultConfigFile = home + '/.config-dialog-watson.yml' parser = argparse.ArgumentParser( description='Text to speech using watson') parser.add_argument('-f', action='store', dest='configFile', default=defaultConfigFile, help='config file', required=False) parser.add_argument('dialog_file', action='store', nargs=1) parser.add_argument('-n', '--name', dest='dialog_name', action='store', help='Dialog name', required=True) parser.add_argument('--clean', dest='clean', action='store_true') args = parser.parse_args() dialog_file = "".join(args.dialog_file) conf = anyconfig.container(defaultConfig) if not os.path.isfile(args.configFile): print "Config file '" + args.configFile + "' doesn't exist." print "Creating it ..." user = raw_input("Watson user: "******"Watson password: "******"".join(args.dialog_name), bconf.url, os.path.dirname(dialog_file) + "/dialog_id_file.txt") if args.clean: watsonClient.clean_dialogs() resp = watsonClient.start_dialog() print '' print bcolors.WARNING + "Watson: " + bcolors.OKBLUE + "\n".join(resp.response) + bcolors.ENDC while True: userResponse = raw_input(bcolors.WARNING + "You: " + bcolors.OKGREEN) resp = watsonClient.converse(userResponse) print bcolors.WARNING + "Watson: " + bcolors.OKBLUE + "\n".join(resp.response) + bcolors.ENDC if userResponse == "bye": break print "" print "Your profile:" for name, value in watsonClient.get_profile().get_data().iteritems(): print "\t" + name + ": " + value if __name__ == "__main__": main()
def main(): defaultConfig = { 'url': 'https://gateway.watsonplatform.net/dialog/api', 'user': '******', 'password': '******', } home = os.path.expanduser("~") defaultConfigFile = home + '/.config-dialog-watson.yml' parser = argparse.ArgumentParser(description='Text to speech using watson') parser.add_argument('-f', action='store', dest='configFile', default=defaultConfigFile, help='config file', required=False) parser.add_argument('dialog_file', action='store', nargs=1) parser.add_argument('-n', '--name', dest='dialog_name', action='store', help='Dialog name', required=True) parser.add_argument('--clean', dest='clean', action='store_true') args = parser.parse_args() dialog_file = "".join(args.dialog_file) conf = anyconfig.container(defaultConfig) if not os.path.isfile(args.configFile): print "Config file '" + args.configFile + "' doesn't exist." print "Creating it ..." user = raw_input("Watson user: "******"Watson password: "******"".join(args.dialog_name), bconf.url, os.path.dirname(dialog_file) + "/dialog_id_file.txt") if args.clean: watsonClient.clean_dialogs() resp = watsonClient.start_dialog() print '' print bcolors.WARNING + "Watson: " + bcolors.OKBLUE + "\n".join( resp.response) + bcolors.ENDC while True: userResponse = raw_input(bcolors.WARNING + "You: " + bcolors.OKGREEN) resp = watsonClient.converse(userResponse) print bcolors.WARNING + "Watson: " + bcolors.OKBLUE + "\n".join( resp.response) + bcolors.ENDC if userResponse == "bye": break print "" print "Your profile:" for name, value in watsonClient.get_profile().get_data().iteritems(): print "\t" + name + ": " + value if __name__ == "__main__": main()