I'm new to programming so you'll have to forgive me for not being well educated on its jargon. I'm starting out on Python as I've just found that
easier out of the many so far. I'm dabbling with simple chatbot code and I've got the text responses and the conversation tree working properly,
however I'd really like the chatbot to SAY the response chosen.
I've set a list of responses (I'll place the code below) to be chosen at random. I'm able to get my computer to say something using:
os.system("say" 'Hello'")
But that's the only way I've found out how. I've tried placing parts of the code into those brackets in the hopes that I'd stumble across a way but
I've so far had no luck. Does anyone know any ideas how I'd get this to work?
HERE'S MY CODE:
import random
import sys
import os
def show_response(options):
---choice = random.randint(0, len(options) -1)
---print(options[choice])
random.seed(None)
while True:
---userInput = input(">>>")
---if userInput in ["Ava, you there?"]:
------list = ["Indeed I am, Sir.", "Yes, Sir. What do you need?", "For you, Sir, always.", "I am now.", "What is it, Sir?", "I'm right here.", "How
may I assist you, Sir?", "How may I assist you?", "You need something, Sir?"]
------choice = random.randint(0, len(list) -1)
------print(list[choice])
---elif userInput in ["Wake up, Ava"]:
------list = ["What is it, Sir?", "How can I help?", "How can I help, Sir?", "Hello, Sir.", "Hello, Sir. Is there anything you need?", "How may I
assist you?", "How may I assist you, Sir?"]
------choice = random.randint(0, len(list) -1)
------print(list[choice])
---elif userInput in ["Hey, Ava"]:
------list = ["What is it, Sir?", "How can I help?", "How can I help, Sir?", "Hello, Sir.", "Hello, Sir. Need anything?", "How may I assist you?",
"How may I assist you, Sir?", "You need something, Sir?"]
------choice = random.randint(0, len(list) -1)
------print(list[choice])
list = ["Responses made by Ava"]
^^ This is what I want to be read out once the console is running. Whatever response is randomly chosen from that list needs to be spoken instantly.
No idea if possible with Python. Again, I'm a rookie and have no clue on where to start. My progress has been achieved with the help of a good friend
but he's never truly worked on a.i/chatbot programming so he has no idea either haha.
Many thanks in advance!
edit on 10-1-2016 by jonwhite866 because: (no reason given)