def juneTriggered(): triggerFlag = False eel.textEdit("Listening...") s.speak("Listening...") #p.playsound("trigger.mp3") #mixer.music.play() print("Triggered")
def askWhatsapp(): global rNumber, messagetxt, mhr, mmnt while True: try: rName = a.askTo("who do you wanna send the message to?") rNumber = c.fetchNumber(rName) print(rName) break except: s.speak("Did not get you") continue while True: try: messagetxt = a.askTo("what is the message?") print(messagetxt) break except: s.speak("Did not get you") continue timeNow = d.datetime.now() mhr = int(timeNow.strftime("%H")) mmnt = int(timeNow.strftime("%M")) + 2 print("here")
def fetchNumber(audioData): try: con = sq.connect("contacts.db") iSql = "select number from contacts where name='" + audioData + "';" cursor = con.execute(iSql) for row in cursor: result = row[0] con.close() return result except: s.speak("Cannot find the contact")
def register(): s.speak("You have not registered yet. Register after setup to continue.") print("Setting up....") time.sleep(5) usrname = a.askTo("What is the username?") passwd = pwd_context.encrypt( a.askTo("What is the password?").lower().replace(" ", "")) hpasswd = pwd_context.encrypt( a.askTo("What is the password for helper?").lower().replace(" ", "")) userData = usrname + "#" + passwd + "#" + hpasswd ufw = open("info.txt", "w") ufw.write(userData) return usrname
def registerEmail(eEmail, ePassword): try: if not path.exists("emailInfo.txt"): emailData = eEmail + "#" + ePassword efw = open("emailInfo.txt", "w") efw.write(emailData) result = "Registered succesfully" else: result = "Already registered" except: result = "Something went wrong!" time.sleep(5) s.speak(result)
def askTo(audioData): while True: try: print(audioData) s.speak(audioData) r = sr.Recognizer() with sr.Microphone() as source: r.adjust_for_ambient_noise(source) audio = r.listen(source) result = r.recognize_google(audio) break except: s.speak("Sorry I did not understand. Try again") return result
def listenAudio(): with sr.Microphone() as source: #r.adjust_for_ambient_noise(source) juneTriggered() try: audio = r.listen(source) audioData = r.recognize_google(audio) eel.textEdit(audioData) print(audioData) speakData = task.doTask(audioData, username) s.speak(speakData) triggerFlag = True except: print("Sorry I did not catch it") s.speak("Sorry i did not understand") triggerFlag = True
def askPass(): s.speak("login to continue.") while True: passkey = a.askTo("Please say the password") passkey = passkey.lower().replace(" ", "") print(passkey) if pwd_context.verify(passkey, passwd): name = usrname s.speak("starting") break if pwd_context.verify(passkey, hpasswd): name = "helper" s.speak("starting") break s.speak("Wrong password. Try again") time.sleep(2) return name
def sendEmail(): try: if usrFileCheck: while True: try: rName = a.askTo("who do you wanna send the message to?") rEmail = c.fetchEmail(rName) if rEmail != False: print(rName) break except: s.speak("Did not get you") continue while True: try: emailtxt = a.askTo("what is the email message?") print(emailtxt) break except: s.speak("Did not get you") continue port = 465 server = smtplib.SMTP_SSL("smtp.gmail.com", port) print(server) server.login(usremail, passwd) print(rEmail) sendem = server.sendmail(usremail, rEmail, emailtxt) print(sendem) result = "Successfully sent" else: s.speak( "You have not registered your email info. Register to send email." ) eel.openEmail() result = "Opening contacts form" except: result = "Failed to send" return result
def editAndSpeak(speakData): eel.textEdit(speakData) s.speak(speakData)
def forceTask(audioData): speakData = task.doTask(audioData, username) s.speak(speakData)