def take_note(s): say("What would you like me to note down?") note = listen() resp = c.execute('INSERT INTO notes VALUES(?,?,?)', ("default", datetime.now().date(), note)) conn.commit() print(resp) return "note saved"
def read_tweet(s): mentions = api.mentions_timeline(count=1) for mention in mentions: a = mention.text b = mention.user.screen_name c = mention.id print(c) say("your last tweet is " + a + " by " + b) say("Do you want me to reply?") choice = listen() if choice == "yes": say("What should i tweet?") text = listen() tweet = "@" + b + " " + text api.update_status(tweet, c) return "Tweet Sent"
def get_result(s): say("Ok. What's your USN?") usn_text = listen() year, dept_code, roll = usn_text.split() usn = "1rv" + year + dept_code.lower() + "%03d" % int(roll) results_form_url = "cgit " s = rq.session() r = s.get(results_form_url) soup = BS(r.content, "html.parser") captcha = soup.find_all("label")[1].text captcha_answer = int(captcha[8]) + int(captcha[12]) print("Captcha:" + captcha_answer) result = getResult(usn, captcha_answer) return str(result)
decoder = Decoder(config) decoder.start_utt() while True: buf = stream.read(1024) decoder.process_raw(buf, False, False) if decoder.hyp() is not None: print([(seg.word, seg.prob, seg.start_frame, seg.end_frame) for seg in decoder.seg()]) print("Detected keyword, restarting search") # # Here you run the code you want based on keyword # say("What can I help you with?") s = listen() if s is None: say("come again?") s = listen() if s is None: say("Sorry, Could not understand") decoder.end_utt() decoder.start_utt() continue print("said " + s) response = process(s) if response is None: say("Could not understand " + s) else: say(response)
def tweet(s): say("What should i tweet?") tweet_text = listen() api.update_status(status=tweet_text) return "Tweet Sent"