def getColumn(num): ans = [] # if(num == 1): # ans = ["x","z","a","i","j","r"] # if(num == 2): # ans = ["b","f","r","g","c","j"] # if(num == 3): # ans = ["o","t","a","g","c","j"] # if(num == 4): # ans = ["b","f","r","u","c","j"] while (True): engine.say("Letters for column " + str(num)) engine.runAndWait() res = speechToText(recognizer, microphone) print(res["text"]) if (helper.checkResponse(res)): # if(1==1): try: col = [] ans = res["text"].strip().lower().split() if (len(ans) == 6): for word in ans: char = word[0] col.append(char) engine.say(col) engine.say("confirm") engine.runAndWait() confirm = helper.checkConfirm() if (confirm): columns.append(col) return # columns.append(col) # return except ValueError: print("Password error")
def getTruthValue(): confirm = helper.checkConfirm() if(confirm): return True elif(not confirm): return False return ""
def checkResults(arr): engine.say("Found multiple choices") for num in arr: question = "Does the symbol look like a" + getPhrase(num) engine.say(question) engine.runAndWait() confirm = helper.checkConfirm() if (confirm): return num + 1 return 0
def read(arr): count = 0 output = "" # engine.say(arr) # engine.runAndWait() for word in arr: count += 1 if (word == "uhhh"): output += "uhhh " elif (word == "what"): output += "what no question " elif (word == "what?"): output += "what question mark " elif (word == "u"): output += "letter u " elif (word == "u"): output += "letters u and r " elif (word == "you"): output += "word you " elif (word == "your"): output += "y o u r " elif (word == "you're"): output += "y o u apostrophe r e " elif (word == "you are"): output += "you space are " elif (word == "uh huh"): output += "u h space h u h " elif (word == "uh uh"): output += "u h space u h " else: output += word + " " # Say 5 words at a time if (count == 5): engine.setProperty('rate', 150) engine.say(output) engine.runAndWait() count = 0 engine.say("Need more words?") confirm = helper.checkConfirm() if (not confirm): return # if __name__ == "__main__": # wordDisplay()
def checkModule(phrase): print("In check module" + phrase) text = phrase.strip().lower().split() print(text) results = [0,0,0,0,0,0,0,0,0,0,0] for word in text: print(word) if (word in bPress): results[0] += 1 if(word in cWires): results[1] += 1 if(word in gLetters): results[2] += 1 if(word in maze): results[3] += 1 if(word in mCode): results[4] += 1 if(word in nDisplay): results[5] += 1 if(word in pword): results[6] += 1 if(word in sSays): results[7] += 1 if(word in sWires): results[8] += 1 if(word in wSequence): results[9] += 1 if(word in wDisplay): results[10] += 1 # Check if results have the same num if(max(results)== 0): return 0 maxNum = [i for i,d in enumerate(results) if d == max(results)] print(results) if(len(maxNum) == 1): runModule(maxNum[0] + 1) else: for i in maxNum: if(i == 0): engine.say("Does it look like a big colored button with a word") elif(i == 1): engine.say("Do you see vertical wires") elif(i == 2): engine.say("Do you see 4 weird symbols") elif(i == 3): engine.say("Do you see a six by six grid with 2 circles") elif(i == 4): engine.say("Do you see an orange flashing light with a button that say tx") elif(i == 5): engine.say("Do you see a number in a display with 4 buttons under it") elif(i == 6): engine.say("Do you see 6 letters with arrows on the top and bottom") elif(i == 7): engine.say("Do you see a red blue green and yellow button") elif(i == 8): engine.say("Do you see 3 to 6 horizontal wires") elif(i == 9): engine.say("Do you see horizontal wires and a b c 1 2 3") elif(i == 10): engine.say("Do you see a word in display with six buttons under") engine.runAndWait() confirm = helper.checkConfirm() if(confirm): runModule(i + 1) return