Example #1
0
from chatbot import Chatbot
import json

if __name__ == "__main__":
    robby = Chatbot("Robby")
    robby.loadEchoRepeat()
    robby.loadConvAI()

    # userResponse = robby.hearMic()
    userResponse = input()
    while 'goodbye' not in userResponse:
        
        reply = robby.reply(userResponse)
        if reply == None:
            reply = robby.convAI(userResponse)
            if reply == None:
                reply = robby.echoRepeat(userResponse)
        robby.speak(reply)
        # userResponse = robby.hearMic()
        print(reply)
        userResponse = input()
    print(robby.name + " has learnt the following from EchoRepeat:", robby.echoRepeatMemory)
    
    print("Save? [y/n]") 
    save = input()
    if save == "y":
        with open('echoRepeat.json', 'w') as fp:
            json.dump(robby.echoRepeatMemory, fp)