def write_note(): tts.speak("What should i write?") print("What should I write?") note = rec_vic.nlproc().lower() file = open('note.txt', 'w') tts.speak("Should i include date and time") print("Should i include date and time?") add_time = rec_vic.nlproc().lower() if 'yes' in add_time or 'sure' in add_time: strTime = datetime.datetime.now().strftime("% H:% M:% S") file.write(strTime) file.write(" :- ") file.write(note) else: file.write(note)
def wolf(qu): try: # print qu.put("Feel free to ask any question.") tts.speak("feel free to ask any question.") # Taking input from user question = rec_vic.nlproc(qu).lower() if question == "none": qu.put("I apologize, I am not able to answer.") tts.speak("I apologize, I am not able to answer.") return # App id obtained by the above steps app_id = 'V56XQ4-23QA5RPPQ9' # Instance of wolf ram alpha # client class client = wolframalpha.Client(app_id) # Stores the response from # wolf ram alpha res = client.query(question) # Includes only text from the response answer = next(res.results).text qu.put(answer) tts.speak(answer) except Exception: # print qu.put("I apologize, I am not able to answer.") tts.speak("I apologize, I am not able to answer.")
def search_google(qu): # print qu.put("What do you want to search?") tts.speak("What do you want to search?") query = rec_vic.nlproc(qu).lower() g_url = "https://www.google.com/search?q=" webbrowser.open(g_url + query)
def pa_strt(qu): from tasks.speak import welc from core import netck from tasks.speak import rec_vic from tasks import tasklist netck.netck(qu) welc.welcom(qu) while True: query = rec_vic.nlproc(qu).lower() #tasks tasklist.tsklst(query, qu)
def sleep_wake(): tts.speak("sleeping now") state.state = 0 print("sleeping now. zzzzzzz !") while True: query = rec_vic.nlproc().lower() if 'wake up' in query: tts.speak("Hi, i am back") print("Hi, I am back.") state.state = 1 break
def wiki(): try: tts.speak("What do you want to search?") print("What do you want to search?") query = rec_vic.nlproc().lower() tts.speak("searching .....") print("searching .....") results = wikipedia.summary(query, sentences=2) tts.speak("According to wikipedia .....") tts.speak(results) except Exception as err: print(err)
def sleep_wake(qu): state.state = 0 tts.speak("sleeping now") # print qu.put("Sleeping now. zzzzzzz !") while True: query = rec_vic.nlproc(qu).lower() if 'wake up' in query: # print qu.put("Hi, I am back.") tts.speak("Hi, i am back") state.state = 1 break
from tasks.speak import welc from core import netck from tasks.speak import rec_vic from tasks import tasklist import os #import googletrans #gt = googletrans.Translator() # main function if __name__ == "__main__": os.system("cls") welc.welcom() netck.netck() while True: query = rec_vic.nlproc().lower() #tasks tasklist.tsklst(query)
def youtube(qu): # print qu.put("What do you want to play?") tts.speak("What do you want to play?") query = rec_vic.nlproc(qu).lower() playonyt(query)
def tsklst(query): if "wikipedia" in query: wiki.wiki() elif 'open youtube' in query: youtube.open_youtube() elif 'youtube' in query or "open video online" in query: youtube.youtube() elif 'open github' in query: open_browser.open_github() elif 'open facebook' in query: open_browser.open_facebook() elif 'login facebook' in query: fbot.fb_login() elif 'open instagram' in query: open_browser.open_instagram() elif 'open google' in query: google.open_google() elif 'search google' in query: google.search_google() elif 'open yahoo' in query: open_browser.open_yahoo() elif 'open gmail' in query: open_browser.open_gmail() elif 'open snapdeal' in query: open_browser.open_snapdeal() elif 'open amazon' in query or 'shop online' in query: open_browser.open_amazon() elif 'open flipkart' in query: open_browser.open_flipkart() elif 'open ebay' in query: open_browser.open_ebay() elif 'close chrome' in query: open_browser.close_chrome() elif 'music from pc' in query or "music" in query or "play music" in query: play_av.music() elif 'video from pc' in query or "video" in query or "play video" in query: play_av.video() elif "write note" in query: notepad.write_note() elif 'show note' in query: notepad.open_note() elif 'close note' in query: notepad.close_note() elif 'read pdf' in query: rd_pdf.pdf_read() elif 'ip address' in query: ip.ip() elif 'joke' in query: jok = (pyjokes.get_joke()) print(jok) tts.speak(pyjokes.get_joke()) elif 'send email' in query or 'email' in query: try: tts.speak("what should I type?") print("What should I type?") query = rec_vic.nlproc().lower() to = "*****@*****.**" memail.sendEmail(to, query) tts.speak("Email has been sent!") print("Email has been sent!") except Exception as err: print(err) tts.speak("I am afraid I can't do this.") elif 'switch window' in query: sys.switch_window() elif "shutdown system" in query: sys.shutdown_system() elif "cancel shutdown" in query: sys.abort_shutdown_system() elif "restart system" in query: sys.restart_system() elif "sleep system" in query: sys.sleep_system() elif "hibernate" in query: sys.hibernate() elif "log off" in query: sys.log_off() elif 'time' in query or 'what time is it?' in query: sys.tell_time() elif 'date' in query or 'what date today?' in query: sys.tell_date() elif 'exit' in query or 'abort' in query or 'stop' in query or 'bye' in query or 'quit' in query or 'good bye' in query: ex_exit = ['good bye', 'ok', 'see you later'] ans_q = random.choice(ex_exit) tts.speak(ans_q) print(ans_q) exit() elif 'sleep' in query: sleep_wake.sleep_wake() elif "what's up" in query or 'how are you' in query: stMsgs = [ 'Just doing my thing!', 'I am fine!', 'Nice!', 'I am nice and full of energy', 'i am ok !' ] ans_q = random.choice(stMsgs) tts.speak(ans_q) print(ans_q) tts.speak("Tell me about you!") how_are_you = rec_vic.nlproc().lower() if 'fine' in how_are_you or 'happy' in how_are_you or 'ok' in how_are_you: tts.speak("Good!") print("Good!") elif 'not good' in how_are_you or 'sad' in how_are_you or 'upset' in how_are_you: tts.speak("oh sorry") print("Oh, sorry!") elif "who are you" in query or "about you" in query or "your details" in query: tts.speak("I am your virtual assistant. A I based computer program.") print("I am your virtual assistant. AI based computer program.") elif "hello" in query or "hello assistant" in query: id = recognize.main() titl = "" if id == "" or id == "Unknown": gen = gender.regen() id = "" if gen == 'Male': titl = 'Sir' elif gen == 'Female': titl = 'Miss' else: titl = "" tts.speak("Hello! " + titl + id + " How May I Help you?") print("Hello! " + titl + id + " How May I Help you?") elif "your name" in query or "sweat name" in query: tts.speak("Call me whatever you want. I have no name.") print("Call me whatever you want. I have no name.") elif "answer me" in query: wolf.wolf() elif "recognize me" in query or "recognize" in query or "recognise me" in query or "recognise" in query or "do you know me" in query or "you know me" in query or "know me" in query: tts.speak("Let see, who you are?") print("Let see, who you are?") id = recognize.main() if id == "" or id == "Unknown": tts.speak("I don't know you.") print("I don't know you.") else: tts.speak("I know you. Your name is " + id) print("I know you. Your name is " + id) elif "register identity" in query or "register face" in query or "identity" in query or "register me" in query: tts.speak("Face registration in progress.") print("Face registration in progress .....") create_dataset.reg_me() tts.speak("Process complete.") print("Process complete.") elif "add face data" in query or "face data" in query: tts.speak("Face data entry in progress.") print("Face data entry in progress .....") create_dataset.add_face() tts.speak("Process complete.") print("Process complete.") else: chatbot.chat(query)
def youtube(): tts.speak("What do you want to play?") print("What do you want to play?") query = rec_vic.nlproc().lower() playonyt(query)