def translate(word): word = word.lower() if word in data: speak('%s means' % word) print(data[word]) speak(data[word]) elif len(get_close_matches(word, data.keys())) > 0: x = get_close_matches(word, data.keys())[0] print(('Did you mean ' + x + ' instead, respond with Yes or No.')) speak('Did you mean ' + x + ' instead, respond with Yes or No.') ans = takeCommand().lower() while ans is None: speak("We didn't understand your entry.") speak('Please state yes or no..') ans = takeCommand().lower() if 'yes' in ans or 'ok' in ans: print(data[x]) elif 'no' in ans: print("Word doesn't exist. Please make sure you spelled it correctly.\n") speak("Word doesn't exist. Please make sure you spelled it correctly.") else: print("Word doesn't exist. Please double check it.") speak("Word doesn't exist. Please double check it.")
def publishTweet(api): print('Hanna: ¿Qué querés twittear?') speak('¿Qué querés twittear?') text = takeCommand().lower() print(f'hanna: vas a twittear, {text}') speak(f'Vas a twittear, {text}') print('Hanna: ¿Estás de acuerdo?') speak('¿Estás de acuerdo?') answ = takeCommand().lower() if answ == 'si' or answ == 'sí': api.update_status(f'{text}') else: pass
def takeNote(text): speak("¿Que nombre le pongo?") noteName = takeCommand() note = (f"{noteName}.txt") with open(note, 'w') as f: f.write(text) subprocess.Popen(['notepad.exe', noteName])
def directory(filepath): """Searches for the file in the provides filepath as Argument and opens it""" file = 'empty' cmd = 'empty' count = 1 ls1 = list() ls2 = list() for name in os.listdir(filepath): ls1.append(count) ls2.append(name) count += 1 file_num = 0 while file_num < len(os.listdir(filepath)): print(ls1[file_num], ls2[file_num]) file_num += 1 print("\nSpeak the file number to open. eg--4") speak("Sure Sir") # SPEAK THE FILE NUMBER TO PLAY THE SONG --- eg. - 4 while file == 'empty': speak('Which File would you like to open') file = command(takeCommand()) if file == 'None': return "None" elif file == 'exit': exit() file = cross_check(file) try: if int(file) < count: break else: file = 'empty' except Exception: file = 'empty' speak('Please speak the file number to open') file = int(file) if 'series' in filepath.lower(): web_series_particular = filepath + "\%s" % ls2[file - 1] web_series = os.listdir(filepath + "\%s" % ls2[file - 1]) # print(web_series) ls3 = list(web_series) count = 1 for a in ls3: print(count, a) count += 1 print("\nSpeak the folder number to open. eg--4\n") # SPEAK THE FILE NUMBER TO OPEN SEASON FOLDER file = 'empty' while file == 'empty': speak("Which season would you like to open") file = command(takeCommand()) if file == 'None': return "None" elif file == 'exit': exit() file = cross_check(file) try: if int(file) < count: break else: file = 'empty' except Exception: file = "empty" speak('Please speak the file number to open') file = int(file) count = 1 for a in ls3: if count == file: break # noinspection PyUnboundLocalVariable web_series_season = web_series_particular + f"{a}" web_series_sea = os.listdir(web_series_particular + "\%s" % a) # print(web_series_sea) ls4 = list(web_series_sea) count = 1 for a in ls4: print(count, a) count += 1 print("\nSpeak the file number to play. eg--4\n") # SPEAK THE FILE NUMBER TO RUN THE EPISODE file = 'empty' while file == 'empty': speak("Which episode would you like to play") file = command(takeCommand()) if file == 'None': return "None" elif file == 'exit': exit() elif file == 'empty': continue file = cross_check(file) try: if int(file) < count: break else: file = 'empty' except Exception: file = "empty" speak('Please speak the file number to open') file = int(file) count = 1 for a in ls4: if count == file: break while cmd == 'empty': speak('Should i close the program while playing series Sir') cmd = command(takeCommand()) speak('playing series') os.startfile(web_series_season + "\%s" % a) # print(web_series_season) if cmd == 'None': return 'None' elif cmd == 'exit': exit() else: while cmd == 'empty': speak('Should i close the program while opening File Sir') cmd = command(takeCommand()) speak('opening file') os.startfile(filepath + '\%s' % ls2[file - 1]) if cmd == 'None': return 'None' elif cmd == 'exit': exit()
server = smtplib.SMTP(host='smtp.gmail.com', port=587) server.ehlo() server.starttls() # enter file_path of password stored in text file file = open('file_path_of_text_file_of_password', 'r') server.login("sender's_main_id", file.readline()) server.send_message(email) server.close() if __name__ == "__main__": wishMe() while True: find = 'empty' cmd = 'empty' query = takeCommand().lower() if 'wikipedia' in query: while find == 'empty': speak('What do you want me to search for ?') find = command(takeCommand()) if find == 'None': speak("Going back to main program...Continuing") continue elif find == 'exit': exit() speak('Searching, %s in Wikipedia...' % find) results = wikipedia.summary(find, sentences=2) speak('According to Wikipedia') print(results + '\n') speak(results)
with open('token.pickle', 'wb') as token: pickle.dump(creds, token) service = build('calendar', 'v3', credentials=creds) return service if __name__ == '__main__': service = auth_googleCalendar() api = func.AuthTwitter() driver = webdriver.Chrome(pathChromeDriver) driver.minimize_window() while True: query = takeCommand().lower() if query in trig.WAKE_TRIGGERS: print("Hanna: Hola , ¿en que te puedo ayudar?") speak("Hola, ¿en que te puedo ayudar?") query = takeCommand().lower() if query in trig.NOTE_TAKING_TRIGGERS: print('Hanna: ¿Que querés que escriba?') speak('¿Que querés que escriba?') text = takeCommand().lower() print('Hanna: ¿Que nombre le pongo?') func.takeNote(text) speak('Listo!') elif query in trig.TIME_TRIGGERS: