def ask_playback(urls, q): if main.run == True: url = str(urls) main.voice_data = recorder.record_audio("Let me know if you like me to play any video from the search results?",q) #print("Voice data is: " + str(main.voice_data)) if main.person_says(["first", "1", "one", "1st", "start", "yes", "sure", "yep", "yeah", "any", "okay", "ok"]): watchvideo(url, 0, q) elif main.person_says(["second", "2", "two", "2nd"]): watchvideo(url, 1, q) elif main.person_says(["third", "3", "three", "3rd"]): watchvideo(url, 2, q) elif main.person_says(["fourth", "4", "four", "4th"]): watchvideo(url, 3, q) elif main.person_says(["fifth", "5", "five", "5th"]): watchvideo(url, 4, q) elif main.person_says(["sixth", "6", "six", "6th"]): watchvideo(url, 5, q) elif main.person_says(["seventh", "7", "seven", "7th"]): watchvideo(url, 6, q) elif main.person_says(["eighth", "8", "eight", "8th"]): watchvideo(url, 7, q) elif main.person_says(["ninth", "9", "nine", "9th"]): watchvideo(url, 8, q) elif main.person_says(["tenth", "10", "ten", "10th"]): watchvideo(url, 9, q) elif main.person_says(["eleventh", "11", "eleven", "11th"]): watchvideo(url, 10, q) elif main.person_says(["No", "nope", "sorry", "Nah", "quit"]): q.put(main.asis_obj.name + ": " + "Okay!" + "\n") speaker.speech_output("Okay!") else: q.put(main.asis_obj.name + ": " + "Sorry, I could not grasp what you meant." + "\n") speaker.speech_output("Sorry, I could not grasp what you meant.") else: pass
def change_name(q): import speaker import main if main.run == True: main.listen("What name do you want me to call you?", q) if main.voice_data != "": import database database.db_nickname(main.voice_data, main.uid, main.email) q.put(main.asis_obj.name + ": " + "Your name has been changed. I will call you by the name " + main.person_obj.name + "\n") speaker.speech_output( "Your name has been changed. I will call you by the name " + main.person_obj.name) else: q.put( main.asis_obj.name + ": " + "Sorry I did not get a new name from you. Do you want to try again?\n" ) speaker.speech_output( "Sorry I did not get a new name from you. Do you want to try again?" ) name_error(q) else: pass
def greeter(q): from datetime import datetime import speaker import main current_time = datetime.now().strftime("%H:%M:%S") hour, minute, second = current_time.split(':') hours = int(hour) if (hours > 4) and (hours < 12): q.put(main.asis_obj.name + ":" + "Good Morning! " + main.person_obj.name + "\n") speaker.speech_output("Good Morning! " + main.person_obj.name) elif (hours == 12): q.put(main.asis_obj.name + ": " + "Good Noon! " + main.person_obj.name + "\n") speaker.speech_output("Good Noon! " + main.person_obj.name) elif (hours > 12) and (hours < 18): q.put(main.asis_obj.name + ": " + "Good Afternoon! " + main.person_obj.name + "\n") speaker.speech_output("Good Afternoon! " + main.person_obj.name) elif (hours >= 18) and (hours < 20): q.put(main.asis_obj.name + ": " + "Good Evening! " + main.person_obj.name + "\n") speaker.speech_output("Good Evening! " + main.person_obj.name) else: q.put(main.asis_obj.name + ": " + "Good Night! " + main.person_obj.name + "\n") speaker.speech_output("Good Night! " + main.person_obj.name)
def chatbot_name(q): import main import speaker q.put(main.asis_obj.name + ": " + "I am " + main.asis_obj.name + " and I am your personal digital assistant.\n") speaker.speech_output("I am " + main.asis_obj.name + " and I am your personal digital assistant.")
def internet_advice(n): if n == 1: speaker.speech_output( "Your internet connection is up. Voice-chat is now available") elif n == 2: speaker.speech_output( "Your internet connection is down. Voice-chat is unavailable") else: pass
def weather_search(q): if main.run == True or main.crun == True: search_term = display_ip() url = "https://google.com/search?q=" + "weather+"+ "of+" + search_term webbrowser.get().open(url) q.put(main.asis_obj.name + ": " + "Here is what I found about weather on " + search_term + "\n") speaker.speech_output("Here is what I found about weather on " + search_term) else: pass
def initial_greeting(q, n): global run run = True if n == 1 and irun == True: q.put(asis_obj.name + ": Hi " + person_obj.name + ", How can I help you?\n") speaker.speech_output("Hi " + person_obj.name + ", How can I help you?") main_page(q)
def open_app(): import speaker import main main.listen("What app do you want to open?") if main.voice_data != "": app = main.voice_data executing = "start " + app + ".exe" import os os.system(executing) else: speaker.speech_output("Sorry I did not get a new name from you") main.main_page()
def records_audio(ask, q): import main if main.run == True and main.irun == True: import speaker import speech_recognition as sr # recognise speech with sr.Microphone() as source: # microphone as source if ask: q.put(main.asis_obj.name + ": " + ask + "\n") speaker.speech_output(ask) r = sr.Recognizer() # initialise a recogniser try: audio = r.listen(source, timeout = 3, phrase_time_limit = 4) # listen for the audio via source main.voice_data = '' try: main.voice_data = r.recognize_google(audio) # convert audio to text except sr.UnknownValueError: # error: recognizer does not understand #print('UnknownValueError: I did not get you.') #print("UR Non-Related = " + str(main.empty_count)) main.voice_data = '' except sr.WaitTimeoutError as e: print("Timeout; {0}".format(e)) print('Please say something') main.voice_data == '' except sr.RequestError: #if main.run == True or main.brun == True: #q.put("Your internet connection is down. Voice-chat is unavailable") #q.put("***Loading text-chat module") #speaker.offline_output('Your internet connection is down. Voice-chat is unavailable. Text-chat module is running.') # error: recognizer is not connected # error: recognizer is not connected voice_data = '' main.run = False main.brun = False except Exception as e: print (str(e)) voice_data = '' except Exception: #print('Exception: Phrase not detected') #print("EX Non-Related = " + str(main.empty_count)) main.voice_data = '' main.voice_data = str(main.voice_data.lower()) if main.voice_data != '': print(main.person_obj.name + ": " + str(main.voice_data)) # print what user said q.put(main.person_obj.name + ": " + main.voice_data + "\n") return str(main.voice_data) else: pass
def game_rps(q): import speaker import main if main.run == True: q.put( main.asis_obj.name + ": " + "Yay! I know a game we both can play. It is called rock paper and scissor." + "\n") speaker.speech_output( "Yay! I know a game we both can play. It is called rock paper and scissor." ) core(q) else: pass
def date_speaker(q): from datetime import datetime import speaker import main month_name = "January" day_note = "st" current_date = datetime.now().strftime("%Y-%m-%d") year, month, day = current_date.split('-') years, months, days = int(year), int(month), int(day) if months == 1: month_name = "January" elif months == 2: month_name = "February" elif months == 3: month_name = "March" elif months == 4: month_name = "April" elif months == 5: month_name = "May" elif months == 6: month_name = "June" elif months == 7: month_name = "July" elif months == 8: month_name = "August" elif months == 9: month_name = "September" elif months == 10: month_name = "October" elif months == 11: month_name = "November" else: month_name = "December" if days == 1 or days == 11 or days == 21 or days == 31: day_note = "st" elif days == 2 or days == 12 or days == 22: day_note = "nd" elif days == 2 or days == 12 or days == 22: day_note = "rd" else: day_note = "th" date = "Today is " + str( days) + day_note + " of " + month_name + ", " + str(years) q.put(main.asis_obj.name + ": " + date + "\n") speaker.speech_output(date)
def background_loop(q): import main import speaker main.empty_count = 0 main.error_count = 0 main.error_count0 = 0 global bg_voice while main.brun: bg_voice = record_audio(q) # get the voice input if person_says(["cutie", "hey cutie", "qt"]) and main.brun == True: q.put(main.asis_obj.name + ": " + "Hi! "+ main.person_obj.name + ", how can I help you?" + "\n") speaker.speech_output("Hi! "+ main.person_obj.name + ", how can I help you?") main.brun = False if main.run == False: main.brun == False
def google_search(q): try: if main.run == True or main.crun == True: if main.person_says (["on google"]): if main.person_says(["of"]): search = main.voice_data.split("of")[-1] search_term = " ".join(search.split("on google") [0:]) elif main.person_says(["for"]): search = main.voice_data.split("for")[-1] search_term = " ".join(search.split("on google") [0:]) else: if main.person_says(["search"]): search = main.voice_data.split("search")[-1] search_term = " ".join(search.split("on google") [0:]) else: search = " ".join(main.voice_data.split(" ")[0:]) search_term = " ".join(search.split("on google") [0:]) elif main.person_says (["in google"]): if main.person_says(["of"]): search = main.voice_data.split("of")[-1] search_term = " ".join(search.split("in google") [0:]) elif main.person_says(["for"]): search = main.voice_data.split("for")[-1] search_term = " ".join(search.split("in google") [0:]) else: if main.person_says(["search"]): search = main.voice_data.split("search")[-1] search_term = " ".join(search.split("in google") [0:]) else: search = " ".join(main.voice_data.split(" ")[0:]) search_term = " ".join(search.split("in google") [0:]) else: if main.person_says(["of"]): search_term = main.voice_data.split("of")[-1] search_term = search_term.replace('google', ' ') elif main.person_says(["for"]): search_term = main.voice_data.split("for")[-1] search_term = search_term.replace('google', ' ') else: if main.person_says(["search"]): search = main.voice_data.split("search")[-1] search_term = " ".join(search.split(" ") [0:]) search_term = search_term.replace('google', ' ') else: search_term = main.voice_data.split(" ")[0:] search_term = search_term.replace('google', ' ') if search_term != '': google_url = "https://google.com/search?q=" + search_term webbrowser.get().open(google_url) q.put(main.asis_obj.name + ": " + "Here is what I found for " + search_term + " on google" + "\n") speaker.speech_output("Here is what I found for " + search_term + " on google") else: speaker.speech_output("Sorry, I got confused in your search query. For example, you can ask me 'search for politics on google'") else: pass except Exception: speaker.speech_output("Sorry, I did not understand what search you wanted. For example, you can ask me 'search for politics on google'")
def time_speaker(q): from datetime import datetime import speaker import main current_time = datetime.now().strftime("%H:%M:%S") hour, minute, second = current_time.split(':') hours, minutes, seconds = int(hour), int(minute), int(second) if hours > 12 and hours < 24: meridian = "pm" hours = hours - 12 elif hours == 24: meridian = "am" hours = hours - 12 elif hours == 12: meridian = "pm" else: meridian = "am" time = "The current time is " + str(hours) + ":" + str( minutes) + meridian + "." #print("Current time = " + time) q.put(main.asis_obj.name + ": " + time + "\n") speaker.speech_output(time)
def wiki_search(search, q): if main.run == True or main.crun == True: if main.voice_data != "" and search != "": import wikipediaapi q.put(main.asis_obj.name + ": " + "Give me a few seconds." + "\n") speaker.speech_output("Give me a few seconds.") wiki_wiki = wikipediaapi.Wikipedia('en') page = wiki_wiki.page(search) if page.exists(): summary = page.summary definition = summary.split(".") [0] q.put(main.asis_obj.name + ": " + definition + ".\n") speaker.speech_output(definition) else: q.put(main.asis_obj.name + ": " + "Sorry, I believe that is a made up word." + "\n") speaker.speech_output("Sorry, I believe that is a made up word.") main.main_page() else: q.put(main.asis_obj.name + ": " + "Sorry I did not get what definition you want. Please ask again." + "\n") speaker.speech_output("Sorry I did not get what definition you want. Please ask again.") main.main_page() else: pass
def watchvideo(url, num, q): try: try: if main.run == True: from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC n = int(num) #print("Video number: " + str(n + 1)) #print("URL: " + str(url)) options = webdriver.ChromeOptions() options.add_argument("start-maximized") options.add_argument('headless') options.add_argument("disable-infobars") options.add_argument("--disable-extensions") driver=webdriver.Chrome(options=options, executable_path=r'chrome_driver/chromedriver.exe', service_log_path='NUL') q.put(main.asis_obj.name + ": " + "Give me a few seconds." + "\n") speaker.speech_output("Give me a few seconds.") driver.get("https://www.youtube.com/results?search_query=" + url) WebDriverWait(driver, 5).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input#search"))).send_keys("Python") driver.find_element_by_css_selector("button.style-scope.ytd-searchbox#search-icon-legacy").click() videos =[my_href.get_attribute("href") for my_href in WebDriverWait(driver, 5).until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, "a.yt-simple-endpoint.style-scope.ytd-video-renderer#video-title")))] driver.quit() #print("Video address:" + str(videos[n])) webbrowser.get().open(videos[n]) else: pass except: if main.run == True: q.put(main.asis_obj.name + ": " + "Give me a few seconds." + "\n") speaker.speech_output("Give me a few seconds.") from youtube_search import YoutubeSearch results = YoutubeSearch(url).to_dict() address =[ d.get('url_suffix', None) for d in results] webbrowser.get().open("www.youtube.com" + str(address[num])) else: pass except Exception: q.put(main.asis_obj.name + ": " + "Sorry, I could not process your request." + "\n") speaker.speech_output("Sorry, I could not process your request.")
def calculate(q): import main import speaker data_length = main.voice_data.split(" ") length = len(data_length) if length > 3: opr = main.voice_data.split()[-2] ppr = main.voice_data.split()[-4] if opr == '+' or opr == 'plus' or ppr == 'add': first_num = int(main.voice_data.split()[-3]) second_num = int(main.voice_data.split()[-1]) adding = first_num + second_num q.put(main.asis_obj.name + ": " + str(first_num) + " plus " + str(second_num) + " is " + str(adding) + "\n") speaker.speech_output( str(first_num) + " plus " + str(second_num) + " is " + str(adding)) elif opr == '-' or opr == 'minus' or ppr == 'subtract': first_num = int(main.voice_data.split()[-3]) second_num = int(main.voice_data.split()[-1]) subtracting = first_num - second_num q.put(main.asis_obj.name + ": " + str(first_num) + " minus " + str(second_num) + " is " + str(subtracting) + "\n") speaker.speech_output( str(first_num) + " minus " + str(second_num) + " is " + str(subtracting)) elif opr == 'x' or ppr == 'multiply': first_num = int(main.voice_data.split()[-3]) second_num = int(main.voice_data.split()[-1]) multiplying = first_num * second_num q.put(main.asis_obj.name + ": " + "Multiplication of " + str(first_num) + " and " + str(second_num) + " is " + str(multiplying) + "\n") speaker.speech_output("Multiplication of " + str(first_num) + " and " + str(second_num) + " is " + str(multiplying)) elif opr == '/' or ppr == 'divide': first_num = int(main.voice_data.split()[-3]) second_num = int(main.voice_data.split()[-1]) dividing = first_num / second_num q.put(main.asis_obj.name + ": " + str(first_num) + " divided by " + str(second_num) + " is " + str(dividing) + "\n") speaker.speech_output( str(first_num) + " divided by " + str(second_num) + " is " + str(dividing)) elif opr == 'power': first_num = int(main.voice_data.split()[-3]) second_num = int(main.voice_data.split()[-1]) powering = first_num**second_num q.put(main.asis_obj.name + ": " + str(first_num) + " to the power of " + str(second_num) + " is " + str(powering) + "\n") speaker.speech_output( str(first_num) + " to the power of " + str(second_num) + " is " + str(powering)) else: q.put( main.asis_obj.name + ": " + "Sorry, I cannot understand the way you ask. For instance, you can ask 'what is 5 + 2?' Or say 'add 5 and 2'" + "\n") speaker.speech_output( "Sorry, I cannot understand the way you ask. For instance, you can ask 'what is 5 + 2?' Or say 'add 5 and 2'" ) elif length == 3: opr = main.voice_data.split()[-2] ppr = main.voice_data.split()[-3] if opr == '+' or opr == 'plus' or ppr == 'add': first_num = int(main.voice_data.split()[-3]) second_num = int(main.voice_data.split()[-1]) adding = first_num + second_num q.put(main.asis_obj.name + ": " + str(first_num) + " plus " + str(second_num) + " is " + str(adding) + "\n") speaker.speech_output( str(first_num) + " plus " + str(second_num) + " is " + str(adding)) elif opr == '-' or opr == 'minus' or ppr == 'subtract': first_num = int(main.voice_data.split()[-3]) second_num = int(main.voice_data.split()[-1]) subtracting = first_num - second_num q.put(main.asis_obj.name + ": " + str(first_num) + " minus " + str(second_num) + " is " + str(subtracting) + "\n") speaker.speech_output( str(first_num) + " minus " + str(second_num) + " is " + str(subtracting)) elif opr == 'x' or ppr == 'multiply': first_num = int(main.voice_data.split()[-3]) second_num = int(main.voice_data.split()[-1]) multiplying = first_num * second_num q.put(main.asis_obj.name + ": " + "Multiplication of " + str(first_num) + " and " + str(second_num) + " is " + str(multiplying) + "\n") speaker.speech_output("Multiplication of " + str(first_num) + " and " + str(second_num) + " is " + str(multiplying)) elif opr == '/' or ppr == 'divide': first_num = int(main.voice_data.split()[-3]) second_num = int(main.voice_data.split()[-1]) dividing = first_num / second_num q.put(main.asis_obj.name + ": " + str(first_num) + " divided by " + str(second_num) + " is " + str(dividing) + "\n") speaker.speech_output( str(first_num) + " divided by " + str(second_num) + " is " + str(dividing)) elif opr == 'power': first_num = int(main.voice_data.split()[-3]) second_num = int(main.voice_data.split()[-1]) powering = first_num**second_num q.put(main.asis_obj.name + ": " + str(first_num) + " to the power of " + str(second_num) + " is " + str(powering) + "\n") speaker.speech_output( str(first_num) + " to the power of " + str(second_num) + " is " + str(powering)) else: q.put( main.asis_obj.name + ": " + "Sorry, I cannot understand the way you ask. For instance, you can ask 'what is 5 + 2?' Or say 'add 5 and 2'" + "\n") speaker.speech_output( "Sorry, I cannot understand the way you ask. For instance, you can ask 'what is 5 + 2?' Or say 'add 5 and 2'" ) else: q.put( main.asis_obj.name + ": " + "Sorry, I cannot understand the way you ask. For instance, you can ask 'what is 5 + 2?' Or say 'add 5 and 2'" + "\n") speaker.speech_output( "Sorry, I cannot understand the way you ask. For instance, you can ask 'what is 5 + 2?' Or say 'add 5 and 2'" )
def response(voice_data, q, n): try: import main if main.run == True or main.crun == True: import random #used for random import speaker # 1: greeting and convos if main.person_says(["hey","hi","hello"]): counters() greeting = ["hey, how can I help you " + main.person_obj.name, "hey, what's up? " + main.person_obj.name, "I'm listening " + main.person_obj.name, "how can I help you? " + main.person_obj.name, "hello " + main.person_obj.name] greet = greeting[random.randint(0,len(greeting)-1)] q.put(main.asis_obj.name + ": " + greet + "\n") speaker.speech_output(greet) elif main.person_says(["good morning","good evening","good afternoon","good noon", "goodnight"]): counters() import times times.greeter(q) elif main.person_says(["how are you","what's up"]): counters() treating = ["I am doing great, " + main.person_obj.name + ". How are you?", "I am fine, " + main.person_obj.name + ". What about you?", "I'm listening to you, " + main.person_obj.name + ". Do you need some help?"] treat = treating[random.randint(0,len(treating)-1)] q.put(main.asis_obj.name + ": " + treat + "\n") speaker.speech_output(treat) elif main.person_says(["you're nice", "fine", "i'm good", "thank you", "thanks", "thankyou", "alright"]): counters() replying = ["That's nice to hear.", "I am happy to hear that.", "I am glad to hear that."] reply = replying[random.randint(0,len(replying)-1)] q.put(main.asis_obj.name + ": " + reply + "\n") speaker.speech_output(reply) elif main.person_says(["joke","jokes", "make me laugh"]): counters() replying = ["Why don't scientists trust atoms? Because........ they make up everything! hehe", "Why doesn't the sun go to college? ..... Because it has a million degrees! buhahaha", "I have many jokes about unemployed people..... sadly none of them work. lol", "What do you call a singing laptop?...... Its A Dell!", "Some people think prison is one word......... but to robbers it's the whole sentence.", "Why couldn't the leopard play hide and seek?...............Because he was always spotted. lol", "I needed a password eight characters long..............So I picked Snow White and the Seven Dwarves. Buhahaha"] reply = replying[random.randint(0,len(replying)-1)] q.put(main.asis_obj.name + ": " + reply + "\n") speaker.speech_output(reply) # 2: naming each other and name changes elif main.person_says(["what is your name","what's your name","tell me your name"]): counters() import names names.chatbot_name(q) elif main.person_says(["what is my name","what's my name","tell me my name"]): counters() import names names.user_name(q) elif main.person_says(["change my name"]): counters() import names names.change_name(q) # 3: quitting program elif main.person_says(["exit", "quit", "goodbye", "bye", "bye bye"]): counters() q.put(main.asis_obj.name + ": " + "Bye! I will miss you! " + main.person_obj.name + "\n") speaker.speech_output("Bye! I will miss you! " + main.person_obj.name) import sys #used for exiting the program try: sys.exit(0) except SystemExit as e: sys.exit(e) # 4: ask time elif main.person_says(["what's the time", "what is the time", "what is current time", "tell me the time","what time"]): counters() import times times.time_speaker(q) elif main.person_says(["what's the date", "what is the date", "what is today's adte", "tell me the date","what date"]): counters() import times times.date_speaker(q) # 5: search google elif main.person_says(["search for", "search"]) and 'youtube' not in main.voice_data and 'weather' not in main.voice_data and 'price' not in main.voice_data: counters() import search search.google_search(q) # 6: search youtube elif main.person_says(["youtube"]): counters() import search search.youtube_search(q) #7 rock paper scisorrs elif main.person_says(["game"]) and n == 1: counters() import game game.game_rps(q) #8 screenshot elif main.person_says(["capture my screen","screenshot"]): counters() import pyautogui #used for screenshot myScreenshot = pyautogui.screenshot() myScreenshot.save('D:/screen.png') speaker.speech_output("The screen has been captured and placed in drive D as screen.png") #9 calculation elif main.person_says(["plus","minus","multiply","divide","power","+","-", "x", "*","/", "add", "subtract"]): counters() import calc calc.calculate(q) #10: search prices of items elif main.person_says(["price of", "price for", "price"]): counters() import search search.price_search(q) #11 weather elif main.person_says(["weather"]): counters() import search search.weather_search(q) #12 definitions elif main.person_says(["definition", "definitions", "what is"]): counters() import search search.definitions(q) #13 Go background elif main.person_says(["go to background", "goto background", "go background"]): counters() import background import speaker q.put(main.asis_obj.name + ": " + "I'm going background. Call my name if you need help." + "\n") speaker.speech_output("I'm going background. Call my name if you need help.") main.brun = True background.background_loop(q) #14 opening apps elif main.person_says(["app", "application"]): counters() import apps apps.open_app() #15 play songs elif main.person_says(["sing me a song", "play a song", "play song"]): counters() from playsound import playsound playsound('song/song.mp3') else: if main.error_count0 == main.error_count: main.empty_count += 1 #print("RE Non-Related = " + str(main.empty_count)) if main.empty_count > 3: counters() import speaker q.put(main.asis_obj.name + ": " + "I'm going background. Call my name if you need help." + "\n") speaker.speech_output("I'm going background. Call my name if you need help.") import background main.brun = True background.bg_play(q) main.error_count0 = main.error_count except: pass
def user_name(q): import main import speaker speaker.speech_output("You are " + main.person_obj.name)
def core(q): import main if main.run == True: import speaker import recorder moves = ["rock", "paper", "scissor"] pmoves = ["rock", "paper", "scissor", "caesar", "peppa"] main.voice_data = recorder.record_audio( "Choose among rock, paper or scissor:", q) if main.voice_data not in pmoves: q.put(main.asis_obj.name + ": " + "Sorry I did not understand. Would you like to try again?" + "\n") speaker.speech_output( "Sorry I did not understand. Would you like to try again?") error(q) else: import random cmove = random.choice(moves) pmove = main.voice_data pmove = name_check(pmove) q.put(main.asis_obj.name + ": " + "You chose " + pmove + "\n") speaker.speech_output("You chose " + pmove) q.put(main.asis_obj.name + ": " + "I chose " + cmove + "\n") speaker.speech_output("I chose " + cmove) if pmove == cmove or (pmove == "peppa" and cmove == "paper") or ( pmove == "caesar" and cmove == "scissor"): q.put( main.asis_obj.name + ": " + "The match is draw. Haha. We both are out of luck today." + "\n") speaker.speech_output( "The match is draw. Haha. We both are out of luck today.") elif pmove == "rock" and cmove == "scissor": q.put(main.asis_obj.name + ": " + "Scissor crushes rock. You won " + main.person_obj.name + "! You are quite lucky today." + "\n") speaker.speech_output("Scissor crushes rock. You won " + main.person_obj.name + "! You are quite lucky today.") elif pmove == "rock" and cmove == "paper": q.put(main.asis_obj.name + ": " + "Paper beats rock. You lost " + main.asis_obj.name + ". Sorry, " + main.person_obj.name + ", I am luckier than you today!" + "\n") speaker.speech_output("Paper beats rock. You lost " + main.asis_obj.name + ". Sorry, " + main.person_obj.name + ", I am luckier than you today!") elif (pmove == "paper" or pmove == "peppa") and cmove == "rock": q.put(main.asis_obj.name + ": " + "Paper beats rock. You won " + main.person_obj.name + "! Looks like someone is luckier today!" + "\n") speaker.speech_output("Paper beats rock. You won " + main.person_obj.name + "! Looks like someone is luckier today!") elif (pmove == "paper" or pmove == "peppa") and cmove == "scissor": q.put(main.asis_obj.name + ": " + "Scissor cuts paper. You lost " + main.asis_obj.name + "! I hope i did not play you out. hehe." + "\n") speaker.speech_output("Scissor cuts paper. You lost " + main.asis_obj.name + "! I hope i did not play you out. hehe.") elif (pmove == "scissor" or pmove == "caesar") and cmove == "paper": q.put(main.asis_obj.name + ": " + "Scissor cuts paper. You're the winner " + main.person_obj.name + ". Aha! You're awesome." + "\n") speaker.speech_output( "Scissor cuts paper. You're the winner " + main.person_obj.name + ". Aha! You're awesome.") elif (pmove == "scissor" or pmove == "caesar") and cmove == "rock": q.put(main.asis_obj.name + ": " + "Scissor crushes rock. I'm the winner " + main.asis_obj.name + "! I love rock and roll! Haha" + "\n") speaker.speech_output("Scissor crushes rock. I'm the winner " + main.asis_obj.name + "! I love rock and roll! Haha") main.voice_data = recorder.records_audio( "Do you want to play again?", q) if main.person_says(["quit", "no", "nope", "nah"]): pass elif main.person_says(["play", "yes", "sure", "okay", "ok"]): core(q) else: q.put( main.asis_obj.name + ": " + "Sorry I did not understand. Would you like to try again?" + "\n") speaker.speech_output( "Sorry I did not understand. Would you like to try again?") error(q) else: pass