def getVoInput(): box.set('') user_command.delete(0, END) speak('listening') text = listen().lower() user_command.insert(0, text) start_new_thread(main, (text, ))
def gen_folder_path(text): mounted() text = text.split() if 'folder' in text: text = ' '.join(text[text.index('folder') + 1:]) elif 'directory' in text: text = ' '.join(text[text.index('directory') + 1:]) else: return "say again with specific command" print(text) opt = [] for index, drive in enumerate(mounted_drives): cmd = "find " + drive + " \(" + except_dirs + " \) -prune -o -type d -iname " + '\'*' + text + '*\'' #print(cmd) r = getoutput(cmd) if text in r.lower(): for i in r.split('\n'): if text in i.lower(): opt.append(i) break #print(opt) if len(opt) == 1: return open_folder(opt[0]) try: if len(opt) != 0: speak('multiple results found') for i, dir in enumerate(opt): print(i + 1, dir) return open_folder(opt[int(input("Enter folder no. to open => ")) - 1]) else: return "No match found" except Exception as ex: print(ex)
def predict(): img=cv2.imread("/home/anmol/Desktop/test/t.jpg") face, rect = detect_face(img) label,s= face_recognizer.predict(face) print("welcome",name) veronica_notify("welcome" + name) speak("welcome " + name) exit()
def getVoInput(): #box.set('') user_command.delete(0, END) speak('listening') text1 = listen().lower() print(text1) text.insert(END,text1) text.insert(END,"\n") user_command.insert(0, text1) start_new_thread(main, (text1,))
def train(): speak("training") veronica_notify("Training") cam=cv2.VideoCapture(0) #time.sleep(10) for i in range(20): r,img=cam.read() cv2.imwrite("/home/anmol/Desktop/s2/"+str(i)+".jpg",img) time.sleep(1) del(cam)
def gen_file_path(text): extension = [''] mounted() text = text.split() if 'play' in text: if 'audio' in text: extension = ['.mp3'] text = ' '.join(text[text.index('audio') + 1:]) elif 'video' in text: extension = ['.mp4', '.avi', '.mkv'] text = ' '.join(text[text.index('video') + 1:]) elif 'file' in text: text = ' '.join(text[text.index('file') + 1:]) elif 'image' in text: extension = ['.jpg', '.png', '.jpeg', '.gif', '.bmp'] text = ' '.join(text[text.index('image') + 1:]) else: return "say again with specific command" print(text) opt = [] for index, drive in enumerate(mounted_drives): for ext in extension: cmd = "find " + drive + " \(" + except_dirs + " \) -prune -o -type f -iname " + '\'*' + text + '*' + ext + '\'' r = getoutput(cmd) #print(r) if text in r.lower(): for i in r.split('\n'): if text in i.lower(): opt.append(i) print(opt) if len(opt) == 1: return open_file(opt[0]) try: if len(opt) != 0: speak('multiple results found') for i, vid in enumerate(opt): print(i + 1, vid[vid.rfind('/') + 1:]) return open_file(opt[int(input("Enter file no. to play => ")) - 1]) else: return "No match found" except Exception as ex: print(ex)
def youtube_link(text): base_url = "https://www.youtube.com" res = requests.get(base_url + "/results?search_query=" + text.replace(' ', '+'), verify=False) try: res.raise_for_status() except Exception as ex: print(ex.args) soup = BeautifulSoup(res.text, 'lxml') links = soup.findAll('h3', {'class': 'yt-lockup-title'}) #.find('a').get('href') speak('here are the results') for i, link in enumerate(links): print(i + 1, link.find('a').get('title')) dl_link = base_url + links[int(input('Enter Video No. to download => ')) - 1].find('a').get('href') #print(dl_link) return get_page("http://en.savefrom.net/#url=" + dl_link) #lucky('site:www.youtube.com "' + text + '"'))
def search_wiki(keyword=''): print('V.E.R.O.N.I.C.A :Trying Wikipedia') #running the query searchResults = wikipedia.search(keyword) #if no result,print no result if not searchResults: print("NO results found") return #Search for page... try block try: page = wikipedia.page(searchResults[0]) except wikipedia.DisambiguationError as err: #selecting first item in list page = wikipedia.page(err.option[0]) #encoding the response to utf-8 wikiTitle = str(page.title.encode('utf-8')) wikiSummary = str(page.summary.encode('utf-8')) #printing result print(wikiSummary) speak('Here is your result') veronica_notify(wikiSummary)
def s_mail(mail_S, mail_R, mail_Sub, mail_M): print('inside func') # mail_ID=input("V.E.R.O.N.I.C.A: Enter Mail Id:") # mail_P=input("V.E.R.O.N.I.C.A: Enter Password:"******"V.E.R.O.N.I.C.A:Enter Your Mail:") # mail_R=input("V.E.R.O.N.I.C.A:Enter Recipents Email:") mail_settings = { "MAIL_SERVER": 'smtp.gmail.com', "MAIL_PORT": 465, "MAIL_USE_TLS": False, "MAIL_USE_SSL": True, "MAIL_USERNAME": mail_S, "MAIL_PASSWORD": '******' } app.config.update(mail_settings) mail = Mail(app) print('settings done') #if __name__ == '__main__': with app.app_context(): msg = Message( subject=mail_Sub, sender=app.config.get("MAIL_USERNAME"), recipients=[mail_R], # replace with your email for testing body=mail_M) speak('sending mail') veronica_notify('Sending Mail') mail.send(msg) speak("Mail Send") veronica_notify("Mail Send") #s_mail()
### Author - Raghav Maheshwari ### import pyperclip from AudioIO import speak #f = open(pyperclip.paste(), 'r') #text = f.readlines() #print(''.join(text)) #speak(''.join(text)) speak(pyperclip.paste()) ''' for i in text: print(i) speak(i) '''
def main(text): #nancy_notify('Virtual Assistant Started') #text = "" #while text != "terminate": #if text == "": # speak('On your mark sir') #else: # speak('ready sir') #text = "youtube results ok jaanu title song" if text == 'mic': speak('listening') print('listening') text = listen().lower() nancy_notify(text) print(text) elif text == '': text = input('Enter command => ') if text == 'q': exit(1) update_log(text) if text in ["who are you", "introduce yourself"]: speak('I am Nancy, your personal assistant.') return elif "describe yourself" in text: speak("I am Nancy, your personal assistant. I use python's speech recognition module " "to understand voice input, and google's text to speech technology to give output.") return elif "toss a coin" in text: if choice(range(1, 11)) % 2 == 0: speak('It is tails') else: speak('It is heads') return elif text in ["throw a dice", "throw a die"]: speak(str(choice(range(1, 7)))) return elif text == "connection problem": nancy_notify('connection problem Nancy exiting...') exit() elif text in ['stop', 'pause']: speak('Suspending') return 'pause' elif text in ["didn't get you", "terminate"]: if text == "terminate": nancy_notify('Virtual Assistant Exited') speak("Bye Bye") exit(1) else: speak(text) # continue ''' elif text in ["stop", "go to sleep"]: speak('Okay sir') stop = StopApp() stop.mainloop() continue ''' #speak('fetching results please wait') if 'folder' in text or 'directory' in text:#match(r'^.*(folder)|(directory) .*$', text): speak(nautilus.gen_folder_path(text)) elif 'drive' in text:#search(r'drive', text): speak(nautilus.gen_drive_path(text)) elif 'meaning' in text or 'define' in text:#search(r'(meaning)|(define)', text): speak(getMeaning(text)) elif 'temperature' in text:#search(r'temperature', text): speak(getTemperature(text)) elif 'run' in text or 'execute' in text:#search(r'(run)|(execute)', text): speak(nautilus.open_gnome(text)) elif 'browse' in text:#search(r'(browse)', text): speak(get_address(text)) elif 'google' in text or 'search' in text:# search(r'(google)|(search)', text): speak(get_result(text)) elif 'download audio' in text:#search(r'download\s(audio)|(song)', text): speak(page_link(' '.join(text.split()[2:]))) elif 'youtube results' in text:#search(r'download\s(video)|(mp4)', text): speak(youtube_link(text[text.find('youtube results of')+len('youtube results of')+1:])) elif 'download lyrics' in text:#search(r'download\s(lyrics)', text): speak(lyrics_down(text)) else: speak(nautilus.gen_file_path(text))
def fb(): webbrowser.open_new_tab("http://www.facebook.com") veronica_notify("There You GO!!") text.insert(END,"Veronica:There You Go!!\n") speak("There You Go!!")
def whatcanido(): text.insert(END,"\nVERONICA:\nThere lots of think i can help you with...\n\n1)Daily news\n2)Browse websites\n3)Download Audio\n4)Download video\nand many more...\nJust tap the microphone\nOr type the text") veronica_notify("There lots of think i can help you with...\n\n1)Daily news\n2)Browse websites\n3)Download Audio\n4)Download video\nand many more...\nJust tap the microphone or type the text") speak("There lots of think i can help you with,Just tap the microphone or type the text")
def insta(): webbrowser.open_new_tab("http://www.instagram.com") veronica_notify("Veronica:There You GO!!") text.insert(END,"There You Go!!\n") speak("There You Go!!")
login() try: animation=pyglet.image.load_animation(LOGO_PATH) animSprite=pyglet.sprite.Sprite(animation) w=animSprite.width h=animSprite.height window=pyglet.window.Window(width=w,height=h) r,g,b,alpha=0.5,0.5,0.8,0.5 pyglet.gl.glClearColor(r,g,b,alpha) pyglet.clock.schedule_once(pyglet.app.exit(),8) @window.event def on_draw(): window.clear() animSprite.draw() pyglet.app.run() except: window.close() speak("Hello sir,here is some daily info for you") veronica_notify("Hello sir,here is some daily info for you") text.insert(END,"Veronica:Hello Sir,here is some daily info for you\n") root.mainloop()
def main(text): update_log(text) if text in ["who are you", "introduce yourself"]: intro = 'I am Veronica, your personal assistant.' speak(intro) veronica_notify(intro) return elif "describe yourself" in text: intro = "I am Veronica, your personal assistant. I use python's speech recognition module to understand voice input, and google's text to speech technology to give output." speak(intro) veronica_notify(intro) return elif "toss a coin" in text: coin = random.randint(1, 2) if coin == 1: reply = "It is Tails" speak('It is tails') veronica_notify('It is tails') elif coin == 2: speak('It is heads') veronica_notify('It is heads') reply = 'It is heads' return reply elif text in ["throw a dice", "throw a die"]: dice = str(random.randint(1, 6)) speak(dice) veronica_notify(dice) return elif text == "connection problem": speak('connection problem exiting') veronica_notify('connection problem exiting...') exit() elif text in ['stop', 'pause']: speak('Suspending') veronica_notify('Suspending') return 'pause' elif text in ["didn't get you", "terminate", 'bye', 'bye bye']: if text == "terminate": veronica_notify('Virtual Assistant Exited') speak("Bye Bye") exit(1) else: speak(text) # continue ''' elif text in ["stop", "go to sleep"]: speak('Okay sir') stop = StopApp() stop.mainloop() continue ''' #speak('fetching results please wait') if 'folder' in text or 'directory' in text: #match(r'^.*(folder)|(directory) .*$', text): speak(nautilus.gen_folder_path(text)) elif 'drive' in text: #search(r'drive', text): speak(nautilus.gen_drive_path(text)) elif 'meaning' in text or 'define' in text: #search(r'(meaning)|(define)', text): speak(getMeaning(text)) veronica_notify(getMeaning(text)) elif 'run' in text or 'execute' in text: #search(r'(run)|(execute)', text): speak(nautilus.open_gnome(text)) veronica_notify(text) elif 'browse' in text: #search(r'(browse)', text): speak(get_address(text)) elif 'google' in text or 'search' in text: # search(r'(google)|(search)', text): speak(get_result(text)) veronica_notify('There you go !') elif 'download audio' in text: youtube_mp3(text) reply = 'Downloaded audio complete' return reply elif 'download video' in text: youtube_mp4(text) reply = 'Downloaded video complete' + text return reply elif 'youtube' in text: #search(r'download\s(video)|(mp4)', text): speak('starting youtube') veronica_notify('starting youtube') reply = 'Starting Youtube' url_Open(text) return reply #speak(youtube_link(text[text.find('youtube results of')+len('youtube results of')+1:])) elif 'download lyrics' in text: #search(r'download\s(lyrics)', text): speak(lyrics_down(text)) elif 'temperature' in text or 'wolfram' in text or 'wikipedia' in text: temp = search(text) speak(temp) veronica_notify(temp) elif 'train' in text: train_veronica() elif 'vlc' in text or 'terminal' in text or 'python' in text or 'lock' in text or 'reboot' in text or 'saavn' in text or 'shutdown' in text or 'system monitor' in text: nautilus.open_gnome(text) return 'there you go' elif 'navigate' in text or 'place' in text or 'locate' in text: fetched = fetch(text) mapopen(fetched) return 'opening maps' elif 'nearby' in text or 'find some' in text or 'shop' in text: mapopen(text) return 'I have found some info for you' else: # #chat(text) # resp=bot.get_response("hello") # veronica_notify(resp) # speak(resp) #are you satisfied if not redirect to google speak(get_result_google(text)) veronica_notify('There you go !') '''else: