def quotes_jessica(a): if str(a) == "Inspire" or str(a) == "inspire": y = ['life','happiness','success','love','family','dedication','work','hard work','friends','lucky'] z = random.choice(y) print( wikiquote.quotes(z,max_quotes = 1) ) pyt.say( wikiquote.quotes(z,max_quotes = 1) ) elif str(a) == "quotes" or str(a) == "Quotes": pyt.say("Search quote about:") y = input(">>>") print( wikiquote.quotes(y,max_quotes = 1) ) pyt.say( wikiquote.quotes(y,max_quotes = 1) ) elif str(a) == "Quote" or str(a) == "quote" : print( wikiquote.quote_of_the_day()) pyt.say( wikiquote.quote_of_the_day() ) #elif str(a) == "Random" or str(a) == "random": # y = ['life','happiness','success','love','family','dedication','work','hard work','friends','lucky'] # z = random.choice(y) # print( wikiquote.quotes(z,max_quotes = 1) ) # pyt.say( wikiquote.quotes(z,max_quotes = 1) ) else: pyt.say("Quotes not found")
def send_mail(): pyt.say("who will be the reciever?") name = input() try: if "Aditi" in name or "aditi" in name: to = config.Aditi if "Rachita" in name or "rachita" in name: to = config.Rachita if "Jasper" in name or "jasper" in name: to = config.EMAIL_ADDRESS if "Apoorva" in name or "apoorva" in name: to = config.Apoorva except: to = str(input("Enter email address")) #pyt.say("Speak the message") pyt.say("Enter the message") msg = input() server = smtplib.SMTP('smtp.gmail.com:587') server.starttls() froma = config.EMAIL_ADDRESS psw = config.PASSWORD server.login(froma, psw) server.sendmail(froma, to, msg) print('Message Sent..') server.quit()
def wea(): weather = Weather(unit=Unit.CELSIUS) location = weather.lookup_by_location("Allahabad") #To find the todays weather: condition = location.condition pyt.say("\nTodays weather is: " + str(condition.text)) print("\nTodays weather is: " + str(condition.text)) pyt.say("Want to find future weather?") ans = input(">>>") #To find weather forcast for next 10 days: if ans == 'Y' or ans == "y" or ans == "Yes" or ans == "yes": forecasts = location.forecast for forecast in forecasts: print("\n Date:" + str(forecast.date)) pyt.say(" On date " + str(forecast.date)) print("Expected :" + str(forecast.text)) pyt.say("The weather is expected to be :" + str(forecast.text)) #print("Highest temperature:" + str(forecast.high)) #print("Lowest temperature:" + str(forecast.low)) else: pyt.say("Okay bye")
def rem(): os.system('clear') print("\nWant to add, read or delete or edit reminder?") pyt.say("Want to add, read or delete or edit reminder?") x = input(">>>") while (not (set(w.exit_words).intersection(x.split()))): #date= input("Enter date in format (DD-MM-YYYY)\n") #To add reminder if "add" in x.split() or "add reminder" in x.split( ) or "Add reminder" in x or "Add" in x.split(): add_reminder_of_a_date() x = input(">>>") #to read the reminder of the date elif "Read" in x.split() or "read" in x.split( ) or "read my reminder" in x or "Read my reminder" in x or "read reminder" in x or "Read reminder" in x or "Read reminders" in x or "read reminders" in x: read_reminder() x = input(">>>") #To edit the reminder elif "Edit" in x.split() or "edit" in x.split() or "Delete" in x.split( ) or "delete" in x.split( ) or "delete reminder" in x or "Delete reminder" in x or "edit reminder" in x.split( ) or "Edit reminder" in x.split(): delete_reminder() x = input(">>>") #if words do not match else: pyt.say("Not understood! Please say again.") x = input(">>>")
def speak(): try: #print("A moment of silence, please...") with m as source: r.adjust_for_ambient_noise(source) print("Set minimum energy threshold to {}".format(r.energy_threshold)) while True: #pyt.say("Say something!") #print("Say something!") with m as source: audio = r.listen(source) print("Got it!") pyt.say("Got it!") try: # recognize speech using Google Speech Recognition value = r.recognize_google(audio) # we need some special handling here to correctly print unicode characters to standard output if str is bytes: # this version of Python uses bytes for strings (Python 2) print("You said {}".format(value).encode("utf-8")) pyt.say("You said {}".format(value).encode("utf-8")) else: # this version of Python uses unicode for strings (Python 3+) print("You said {}".format(value)) pyt.say("You said {}".format(value)) except sr.UnknownValueError: print("Oops! Didn't catch that") pyt.say("Oops! Didn't catch that") except sr.RequestError as e: print("Uh oh! Internet problem") pyt.say("Uh oh! Internet problem") except KeyboardInterrupt: pass return value
def handle(): messages=["Bye-Bye","TA-TA","I am going to sleep","See you soon","Have a nice day"] message=random.choice(messages) pyt.say(message) command = "/usr/bin/sudo /sbin/shutdown -r now" import subprocess process = subprocess.Popen(command.split(), stdout = subprocess.PIPE) output = process.communicate()[0]
def newss(url): open_page = requests.get(url).json() article = open_page["articles"] results = [] for ar in article: results.append(str(ar["title"])) for i in range(len(results)): print(i + 1, results[i]) pyt.say(results[i])
def delete_reminder(): try: pyt.say("Want to remove datewise or remove all?") i = input( "Press \n remove all. \n remove according to date. \n quit\n") if "delete all" in i or "Delete all" in i or "all" in i.split( ) or "All" in i.split(): try: f = open(reminder_path, 'r+') for line in f: continue f.seek(0) f.truncate() f.close() except: pyt.say("Cannot remove") elif "delete according to date" in i or "Delete according to date" in i or "date" in i.split( ) or "Date" in i.split() or "datewise" in i.split( ) or "Datewise" in i.split(): f = open(reminder_path, "r+") data = [] for line in f: print(line) data.append(line) pyt.say("Tell the date of the reminder of format:") print("DD/MM/YYYY") dated = input() datein = valid_date(dated) dateing = str(datein) new_data = [] for line in data: if dateing in line: if new_data in line: pyt.say("No reminder in file") else: continue else: new_data.append(line) f.seek(0) f.writelines([line for line in new_data]) f.truncate() f.close() elif "quit" in i.split() or "Quit" in i.split() or "Exit" in i.split( ) or "exit" in i.split(): exit() except: pyt.say("Wrong choice")
def add_reminder_of_a_date(): pyt.say("Tell the date of the reminder of format:") print("DD-MM-YYYY\n") dated = input() dateing = valid_date(dated) datein = str(dateing) #print(dateing) present = date.today() #print(present) while datein < str(present): pyt.say("Reminder cannot be set before today.Enter new date ") print("DD-MM-YYYY\n") dated = input() dateing = valid_date(dated) datein = str(dateing) pyt.say("Now set the reminder") reminder_text = input(">>>") with open(reminder_path, "a") as f_reminder: f_reminder.write(str(datein) + "-" + str(reminder_text) + "\n") f_reminder.close() pyt.say("reminder succesfully set.")
def valid_date(dates): while True: dd, mm, yy = (int(x) for x in dates.split('-')) try: s = datetime.date(yy, mm, dd) if s: return s else: pyt.say("Invalid date, enter again") dates = input("DD-MM-YYYY\n") except: pyt.say("Invalid date, enter again") dates = input("DD-MM-YYYY\n")
def wolf(): pyt.say(" Wolfram Alpha Module, Ask anythin and see the magic! ") pyt.say("What's the question?") x = input("Question: ") while (not (set(w.exit_words).intersection(x.split()))): try: client = wolframalpha.Client(App_ID) rest = client.query(x) answer = next(rest.results).text print(answer) pyt.say(answer) except: pyt.say("Wrong question.Try again!") pyt.say("Ask again") x = input("Question: ")
def music(): for file in os.listdir("/home/apoorva/Desktop/Jessica/music"): if file.endswith(".wav") or file.endswith(".mp3"): print("\n" + file) pyt.say( "To stop the music press Ctrl+C ...These are the files in the folder. Which file you want to play?" ) file_name = input("\nFile name:\n") flag = 0 for file in os.listdir("/home/apoorva/Desktop/Jessica/music"): if file_name in file: flag = 1 if flag == 0: pyt.say("File name not exists.") else: os.system("aplay /home/apoorva/Desktop/Jessica/music/" + file_name)
def speak_news(): pyt.say(" 1 National News. or 2 International News. \n") print("\n 1.National News \n 2.International News \n") x = input(">>>") if "National" in x.lower().split() or "national" in x.lower().split(): print("\n1.1.Headlines \n 1.2.Sports \n 1.3.Buisness \n") x = input(">>>") if "headlines" in x.lower().split() or "highlights" in x.lower().split() or "todays_news" in x.lower().split(): url = config.Times_Of_India newss(url) elif "sports" in x.lower().split() or "Sports" in x.lower().split(): url = config.BBC_sports_news newss(url) elif "buisness" in x.lower().split() or "Buisness" in x.lower().split(): url = config.Financial_Time newss(url) elif "International" in x.lower().split() or "international" in x.lower().split(): print("\n 1.USA \n 2.UK\n") x = input(">>>") if "usa" in x.lower().split() or "USA" in x.lower().split(): url = config.USA_Today newss(url) elif "uk" in x.lower().split() or "UK" in x.lower().split(): url = config.Buisness_Insider_UK newss(url) #elif w.exit_words in x.split(): exit(0) else: pyt.say("Exiting module") #speak_news()
def read_reminder(): #try: pyt.say("Want to read datewise or read all?") i = input("Press \n read all. \n read according to date. \n quit\n") if "read all" in i or "Read all" in i or "all" in i.split( ) or "All" in i.split(): f = open(reminder_path, "r") for line in f: try: print(line) pyt.say(line) except: print("File empty") f.close() elif "read according to date" in i or "Read according to date" in i or "date" in i.split( ) or "Date" in i.split() or "datewise" in i.split( ) or "Datewise" in i.split(): pyt.say("Enter the date of format:") print("DD-MM-YYYY") dated = input() datein = valid_date(dated) #print(datein) dateing = str(datein) f = open(reminder_path, "r") flag = 0 for line in f: try: if dateing in line: print(line) pyt.say(line) flag = 1 else: flag = 0 except: pyt.say("Error in the program") if flag == 0: print("Nothing on the calendar on this date") f.close() elif "quit" in i.split() or "Quit" in i.split() or "Exit" in i.split( ) or "exit" in i.split(): exit()
def add_reminder_of_a_date(): pyytsx3_jessica.say("Tell the date of format:") print("DD-MM-YYYY\n") dated = input() dateing = valid_date(dated) datein = str(dateing) #print(dateing) present = date.today() #print(present) #while datein < str(present): # pyytsx3_jasper.say("Reminder cannot be set before today.Enter new date ") # print("DD-MM-YYYY\n") # dated = input() # dateing = valid_date(dated) # datein = str(dateing) pyytsx3_jessica.say("Now tell the story") reminder_text = input(">>>") with open(reminder_path,"a") as f_reminder: f_reminder.write( str(datein) + "-" + str(reminder_text) + "\n") f_reminder.close() pyytsx3_jessica.say("your memory is safe here!")
def schedule(): file_name = "reminder_jessica.txt" todays = date.today() #print(todays) dates = str(todays) f = open(file_name, "r") flag = 0 for line in f: if dates in line: #print (line) #pyt.say(line) flag = flag + 1 #print(flag) if flag: pyt.say("Reminder exists.If you want to read it press Y/y") print("Reminder exists.If you want to read it press Y/y") ans = input(">>>") if ans == 'Y' or ans == "y" or ans == "Yes" or ans == "yes": print(line) pyt.say(line) else: pyt.say("Ookay") f.close() #schedule()
def diary(): print("Sciccy : Tell me all about today") pyytsx3_jessica.say("Feel free to share") x = input(">>>") #date= input("Enter date in format (DD/MM/YYYY)\n") while (not(set(w.exit_words).intersection(x.split()))): if "add" in x.split() or "Add" in x.split(): add_reminder_of_a_date() x = input(">>>") elif "read" in x.split() or "Read" in x.split(): read_reminder() x = input(">>>") elif "delete" in x.split() or "Delete" in x.split(): delete_reminder() x = input(">>>") elif "thanku" in x.split() or "Thanku" in x.split() or "thanks" in x.split() or "Thanks" in x.split() or "thank you" in x or "Thank you" in x: quit() x = input(">>>") else: pyytsx3_jessica.say("Entry do not match") x = input(">>>")
def add_notes(file_name): pyt.say("Do you want to add notes for today?") ans = input(config.Name + ": ") if ans == "Yes" or ans == "yes" or ans == 'y' or ans == "Y": todays = date.today() dates = str(todays) else: pyt.say("Enter the date of format:\n") dateing = input("DD/MM/YYYY\n") dateing = valid_date(dateing) dates = str(dateing) #Searching for the date in file pyt.say("Start adding notes") notes_text = input() with open(file_name, "a") as f_notes: f_notes.write(str(dates) + " - " + notes_text + "\n") f_notes.close() pyt.say("Notes noted")
def wiki(): pyt.say(" What are you searching for? ") x = input(">>>") while (not (set(exit_words).intersection(x.split()))): print(wikipedia.summary(x, sentences=2)) pyt.say(wikipedia.summary(x, sentences=2)) pyt.say("search for more?") y = input(">>>") if "yes" in y.lower().split() or "y" in y.lower().split( ) or "Y" in y.lower().split(): x = input(">>>") else: break
def read_notes(file_name): pyt.say("Want to read the whole file or read a particular date") i = input(">>>") if "read all" in i or "Read all" in i or "all" in i.split( ) or "All" in i.split(): f = open(file_name, "r") for line in f: try: print(line) pyt.say(line) except: pyt.say("File empty") elif "read according to date" in i or "Read according to date" in i or "date" in i.split( ) or "Date" in i.split() or "datewise" in i.split( ) or "Datewise" in i.split(): pyt.say("Enter the date of format:\n") dated = input("DD/MM/YYYY\n") datein = valid_date(dated) dates = str(datein) f = open(file_name, "r") flag = 0 for line in f: try: if dateing in line: print(line) pyytsx3_jasper.say(line) flag = 1 else: flag = 0 except: pyytsx3_jasper.say("Error in the program") if flag == 0: print("Nothing on the calendar on this date") f.close()
def cal(): print( " Searching for \n Current month \n Calendar of specific month \n Calendar of specific year \n Leapyear \n If yes, then say it!.\n" ) pyt.say( " Searching for Current month calendar of specific month and year calendar of specific year leapyear, If yes, then say it." ) x = input(">>>") while (not (set(exit_words).intersection(x.split()))): #To print the calendar of current month if "this month" in x or "current month" in x or "This month" in x or "Current month" in x or "Calendar of this month" in x or "calendar of this month" in x: now = datetime.datetime.now() mm = now.month yy = now.year print(calendar.month(yy, mm)) x = input(">>>") #To print the calendar of a specific month and year elif "Calendar of month " in x or "calendar of month" in x or "specific month" in x or "Specific month" in x or "month" in x.split( ) or "Month" in x.split(): yy = int(input("Year?")) mm = int(input("month")) print(calendar.month(yy, mm)) x = input(">>>") #To print the calendar of a specific year elif "Calendar of specific year" in x or "calendar of specific year" in x or "specific year" in x or "Specific year" in x: yy = int(input("Year?")) print(calendar.calendar(yy)) x = input(">>>") #To check a leap year elif "leapyear" in x.split(): yy = int(input("year?")) pyt.say(calendar.isleap(yy)) x = input(">>>") #if words do not match else: pyt.say("Not understood! Please say again.") x = input(">>>")
def calc(): pyytsx3_jessica.say( "This module can simply add or subtract or multiply or divide two numbers" ) z = input(">>>") while (not (set(w.exit_words).intersection(z.split()))): #To add if "add" in z.split() or "Add" in z.split(): s = 0 x = int(input("the first number")) y = int(input("the second number")) s = x + y print(s) pyytsx3_jessica.say(s) z = input(">>>") #to subtract if "subtract" in z.split() or "Subtract" in z.split(): x = int(input("the first number")) y = int(input("the second number")) diff = x - y print(diff) pyytsx3_jessica.say(diff) z = input(">>>") #To multiply if "multiply" in z.split() or "Multiply" in z.split(): x = int(input("the first number")) y = int(input("the second number")) mul = x * y print(mul) pyytsx3_jessica.say(mul) z = input(">>>") #To divide if "divide" in z.split() or "Divide" in z.split(): x = float(input("the first number")) y = float(input("the second number")) div = divide(x, y) print(div) pyytsx3_jessica.say(div) z = input(">>>") #Other words else: pyytsx3_jessica.say("Words didnot matched. please say again!") z = input(">>>") #calc()
def delete_notes(file_name): try: pyt.say("Want to remove datewise or remove all?") i = input("Want to remove a file or remove according to date") if "delete all" in i or "Delete all" in i or "all" in i.split( ) or "All" in i.split(): try: f = open(file_name, 'r+') for line in f: continue f.seek(0) f.truncate() f.close() files = "/home/apoorva/Desktop/jasper/Jessie/" + str(file_name) print(files) if os.path.isflie(files): pyt.say("Removing file" + str(files)) os.remove(files) else: pyt.say("File not found") except: pyt.say("Cannot remove") elif "delete according to date" in i or "Delete according to date" in i or "date" in i.split( ) or "Date" in i.split() or "datewise" in i.split( ) or "Datewise" in i.split(): f = open(file_name, "r+") data = [] #for line in f: # print (line) # data.append(line) pyt.say("Tell the date of the reminder of format:") print("DD/MM/YYYY") dated = input() if dated == "today": todays = dated.today() dates = str(todays) else: datein = valid_date(dated) dates = str(datein) new_data = [] for line in data: try: if dates in line: continue else: new_data.append(line) except: print("Date not found") f.seek(0) f.writelines([line for line in new_data]) f.truncate() f.close() except: pyt.say("Wrong choice")
def notes(): os.system('clear') pyt.say( " Want to read add or delete notes?. To exit the program type exit.") print( " \nWant to read add or delete notes?. \nTo exit the program speak exit" ) x = input(">>>") while (not (set(w.exit_words).intersection(x.split()))): #To add reminder if "add" in x.split() or "add reminder" in x.split( ) or "Add" in x.split() or "Add reminder" in x: try: flag = find_files() if flag == 0: pyt.say( "No file found, Enter the name of new file with extension." ) file_name = input("File Name:") else: pyt.say("Files are: ") for file in os.listdir("/home/apoorva/Desktop/Jessica"): if file.endswith(".txt"): print(file) pyt.say("Enter file name to open a file with extension") file_name = input("File Name:") except Exception as e: print(str(e)) add_notes(file_name) x = input(">>>") #to read the reminder of the date elif "Read" in x.split() or "read" in x.split( ) or "read my reminder" in x or "Read my reminder" in x or "read reminder" in x or "Read reminder" in x or "Read reminders" in x or "read reminders" in x: #try: flag = find_files() if flag == 0: pyt.say("No file found") else: pyt.say("Files are: ") for file in os.listdir("/home/apoorva/Desktop/Jessica"): if file.endswith(".txt"): print(file) pyt.say("Enter file name to read a file with extension") file_name = input("File Name:") #except Exception as e: # print(str(e)) if file_name in os.listdir("/home/apoorva/Desktop/Jessica"): read_notes(file_name) elif not (file_name in os.listdir("/home/apoorva/Desktop/Jessica")): while (not (file_name in os.listdir("/home/apoorva/Desktop/Jessica"))): pyt.say("File not found.Enter again.") file_name = input("File Name:") if file_name in os.listdir("/home/apoorva/Desktop/Jessica"): read_notes(file_name) x = input(">>>") #To edit the reminder elif "Edit" in x.split() or "edit" in x.split() or "Delete" in x.split( ) or "delete" in x.split( ) or "delete reminder" in x or "Delete reminder" in x or "edit reminder" in x.split( ) or "Edit reminder" in x.split(): try: flag = find_files() if flag == 0: pyt.say("No file to delete") else: pyt.say("Files are: ") for file in os.listdir("/home/apoorva/Desktop/Jessica"): if file.endswith(".txt"): print(file) pyt.say("Which file to delete?") file_name = input("File Name:") except Exception as e: print(str(e)) delete_notes(file_name) x = input(">>>") #To end the calendar module elif "thanks" in x.split() or "thanku" in x.split( ) or "Thanks" in x.split() or "Thanku" in x.split(): pyt.say("Your welcome") #if words do not match else: pyt.say("Not understood! Please say again.") x = input(">>>")
def today_date(): pyt.say("Today's date is:") today = date.today() pyt.say(today) print(today)
HH, MM, SS = (int(i) for i in time_now.split(':')) if HH >= 24 and HH < 12: wi = "Good morning" elif HH >= 12 and HH <= 16: wi = "Good afternoon" elif HH >= 16 and HH <= 21: wi = "Good evening" else: wi = "Good night" return wi wi = wish_now() pyt.say(wi + config.Name + " ") #print(str(wi) + " " + str(config.Name)) os.system('clear') sch.schedule() x = str(input(config.Name + ":")) while True: #1.Wishing if list(set(x.split()) & set(w.wishing_words)): messages = ["Hi", "Hey", "Hello", "Hola"] message = random.choice(messages) #pyt.say(message +" " + config.Name ) pyt.say("What can i help you with?") x = str(input(config.Name + ":"))
def cal_days(a): if a == 0: print("MONDAY") pyt.say("MONDAY") if a == 1: print("TUESDAY") pyt.say("TUESDAY") if a == 2: print("WEDNESDAY") pyt.say("WEDNSDAY") if a == 3: print("THURSDAY") pyt.say("THRURSDAY") if a == 4: print("FRIDAY") pyt.say("FRIDAY") if a == 5: print("SATURDAY") pyt.say("SATURDAY") if a == 6: print("SUNDAY") pyt.say("SUNDAY")