Exemplo n.º 1
0
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
Exemplo n.º 2
0
if TTS_ENGINE == "espeak":
    try:
        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
Exemplo n.º 3
0
BOT_INFO = {
    "name": "Amanda",
    "birthday": "July 5th 2017",
    "location": "Kanpur",
    "master": "I have no Master",
    "website":"follow me on twitter",
    "gender": "Female",
    "age": "20",
    "size": "",
    "religion": "Humanity",
    "party": "All night !"
}

k = MyKernel()
k.learn("aiml/standard/std-startup.xml")
k.respond("LOAD AIML B")

for key,val in BOT_INFO.items():
	k.setBotPredicate(key,val)

class PopupBox(ModalView):
    '''
    :Events:
        `on_open`:
            Fired when the Popup is opened.
        `on_dismiss`:
            Fired when the Popup is closed. If the callback returns True, the
            dismiss will be canceled.
    '''
Exemplo n.º 4
0
if TTS_ENGINE == "espeak":
    try:
        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