class ChitChat(object): def __init__(self): self.BOT_PREDICATES = { "name": "KanoBot", "birthday": "January 1st 1969", "location": "London", "master": "Judoka", "website": "https://github.com/brandonjackson/make-chatterbot", "gender": "", "age": "", "size": "", "religion": "", "party": "" } self.DEVNULL = open(os.devnull, 'wb') self.k = MyKernel() # Load the AIML files on first load, and then save as "brain" for speedier startup if os.path.isfile("cache/standard.brn") is False: self.k.learn("aiml/standard/std-startup.xml") self.k.respond("load aiml b") self.k.saveBrain("cache/standard.brn") else: self.k.loadBrain("cache/standard.brn") # Give the bot a name and lots of other properties for key, val in self.BOT_PREDICATES.items(): self.k.setBotPredicate(key, val) # Start Infinite Loop def chat(self, sentence): # Prompt user for input # input = raw_input("> ") input = sentence # Send input to bot and print chatbot's response matchedPattern = self.k.matchedPattern( input) # note: this has to come before the # call to respond as to reflect # the correct history response = self.k.respond(input) return response
subprocess.call(["espeak","-q","foo"]) except OSError: TTS_ENABLED = False print "Warning: espeak command not found, skipping voice generation" else: # non-espeak TTS engine being used pass # Create Kernel (using our custom version of the aiml kernel class) k = MyKernel() # Load the AIML files on first load, and then save as "brain" for speedier startup if os.path.isfile("cache/standard.brn") is False: #FIXME undo this. k.learn("aiml/std-startup.xml") k.respond("load aiml b") k.saveBrain("cache/standard.brn") else: k.loadBrain("cache/standard.brn") # Give the bot a name and lots of other properties for key,val in BOT_PREDICATES.items(): k.setBotPredicate(key, val) # Init STT engine recognizer = sr.Recognizer() # Start Infinite Loop while True: # Prompt user for input setEyes(0) #input = raw_input("> ")
subprocess.call(["espeak", "-q", "foo"]) except OSError: TTS_ENABLED = False print "Warning: espeak command not found, skipping voice generation" else: # non-espeak TTS engine being used pass # Create Kernel (using our custom version of the aiml kernel class) k = MyKernel() # Load the AIML files on first load, and then save as "brain" for speedier startup if os.path.isfile("cache/standard.brn") is False: k.learn("aiml/standard/std-startup.xml") k.respond("load aiml b") k.saveBrain("cache/standard.brn") else: k.loadBrain("cache/standard.brn") # Give the bot a name and lots of other properties for key, val in BOT_PREDICATES.items(): k.setBotPredicate(key, val) # Start Infinite Loop while True: # Prompt user for input input = raw_input("> ") # Send input to bot and print chatbot's response matchedPattern = k.matchedPattern( input) # note: this has to come before the
subprocess.call(["espeak", "-q", "foo"]) except OSError: TTS_ENABLED = False print "Warning: espeak command not found, skipping voice generation" else: # non-espeak TTS engine being used pass # Create Kernel (using our custom version of the aiml kernel class) k = MyKernel() # Load the AIML files on first load, and then save as "brain" for speedier startup if os.path.isfile("brain.brn") is False: k.learn("inizializzazione.xml") k.respond("load aiml b") k.saveBrain("brain.brn") else: k.loadBrain("brain.brn") # Give the bot a name and lots of other properties for key, val in BOT_PREDICATES.items(): k.setBotPredicate(key, val) # Start Infinite Loop while True: # Prompt user for input input = raw_input("> ") # Send input to bot and print chatbot's response matchedPattern = k.matchedPattern( input) # note: this has to come before the