Just started learning programming and started dabbling with simple chatbot code. I've got responses in text, however I want my computer (Mac) to speak the response AND ONLY the response at the same time as it appears. Here's the 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])
If this is a repeat I apologies. I'm more in need of fitting the solution within this structure though just to help me learn on where it's placed and how to use it.
NOTE: This isn't a dupe of the question marked. Although the question this is supposedly duping does allow you to turn text to speech, it does not deal with turning listed random responses into speech, which is what I needed to do. It did however allow me to get the speech working though so thank you. I've found the answer elsewhere and placed it below.