PATH = os.path.dirname(os.path.abspath(sys.argv[0])) Config = ConfigParser.ConfigParser() Config.read(PATH + "\config.ini") Config.sections() CONFIG_PORT = Config.get("LINKS", 'Port') CONFIG_WEBKEY = Config.get("LINKS", 'Key') KEY = None try: CONFIG_APIKEY = Config.get("food2fork", 'Key') if CONFIG_APIKEY: KEY = CONFIG_APIKEY except Exception as e: pass AI = pytron.Client() random.seed() def reverse_enumerate(iterable): """ Enumerate over an iterable in reverse order while retaining proper indexes """ return itertools.izip(reversed(range(len(iterable))), reversed(iterable)) print(" *** Welcome to the bad ass motherfucking recipe finder!!! ***") AI.talk("Welcome to the badass motherfucking recipe finder!!!") print(" -Powered by the motherfucking food2fork API- \n") AI.talk("-Powered by the motherfucking food to fork API!!")
import time def main(): while True: try: query = AI.listen('Pytron') if query == 'quit': break elif query == "Play music": # This part gets the confirmation. var_name = "Answer" # The variable where if AI.GetConfirmation(var_name, conf_speech="Do you want to play music?", speech_on_yes="Right away", speech_on_no="Cancelled"): # If confirmation returns true from a yes response, this gets called. AI.emulate_speech('play music') except Exception as e: AI.talk(str(e)) break AI.talk('Goodbye.') if __name__ == '__main__': AI = pytron.Client() # Initialize Links main()