def set_Reminder(self): Speaking.speak(self, "at which hour you want to set the reminder sir") time = Time() query = Speaking.takeCommand(self).lower() if query[0] == '1': if query[1] == '2' or query[1] == '0' or query[1] == '1': userhour = query[0:2] usermin = query[3:5] time_meridiem = query[6:9] print(time_meridiem) print(usermin) self.get_Reminder(userhour, usermin, time_meridiem) else: userhour = query[0] usermin = query[2:4] time_meridiem = query[5:8] print(time_meridiem) Speaking.speak( self, "The Alarm is set at" + userhour + "hours" + usermin + "Minutes Sir") # print("The Alarm is set at "+userhour+" hours "+usermin+" Minutes Sir") list = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'} if userhour in list: userhour = "0" + userhour while (True): if (time.get_Reminder(userhour, usermin, time_meridiem) == True): print("Hello") break else: print("HI") self.query2(userhour, usermin, time_meridiem) continue
def query(self): speaking = Speaking() speaking.WishMe() take= Take_Query() while (True): query = speaking.takeCommand().lower() take.all_the_queries(query) continue
def query(self): speaking = Speaking() speaking.WishMe() # speaking.Graphics() time = Time() date = Date() while (True): query = speaking.takeCommand().lower() self.all_the_queries(query) continue
def List_Making(self): speaking = Speaking() speaking.speak("how many elements do you want in the list sir") query = speaking.takeCommand() query = (int)(query) list = [] speaking.speak("Tell me the elements in the list sir") for i in range(query): item = speaking.takeCommand() list.append(item) speaking.speak("the" + item + "is added in the list sir") print(list)
def tellTime(self, counter): time = str(datetime.datetime.now()) hour = time[11:13] min = time[14:16] if counter == 0: return hour, min else: print("The time is sir" + hour + "Hours and" + min + "Minutes") Speaking.speak( self, "The time is sir" + hour + "Hours and" + min + "Minutes") return hour, min
def telldate(self): day = str(date.today()) print(day) todaydate = day[8:10] this_Month = day[5:7] # print(todaydate + "") # print(this_Month) this_year = day[0:4] # print(this_year) if todaydate == '01': dateno = "First" elif todaydate == '21': dateno = "Twenty First" elif todaydate == '31': dateno = "Thirty First" elif todaydate == '02': dateno = "Second" elif todaydate == '03': dateno = "Third" elif this_Month == '01': month = "January" elif this_Month == '02': month = "February" if this_Month == '03': month = "March" if this_Month == '04': month = "April" if this_Month == '05': month = 'May' if this_Month == '06': month = 'June' if this_Month == '07': month = 'July' if this_Month == '08': month = 'August' if this_Month == '09': month = 'September' if this_Month == '10': month = 'October' if this_Month == '11': month = 'November' if this_Month == '12': month = 'December' elif todaydate == '03': dateno = "Third" if todaydate == '01' or todaydate == '02' or todaydate == '03' or todaydate == '31' or todaydate == '21': Speaking.speak(self, dateno + month + this_year) else: Speaking.speak(self, todaydate + month + this_year)
def tell_days(self, days): dict_day = { 1: 'Monday', 2: 'Tuesday', 3: 'Wednesday', 4: 'thursday', 5: 'friday', 6: 'saturday', 7: 'sunday', 0: 'sunday' } if days in dict_day.keys(): days = dict_day[days] # print(dict_day[days]) Speaking.speak(self, "The days is " + days)
def tellDay(self): day = datetime.datetime.today().weekday() + 1 Day_dict = { 1: 'Monday', 2: 'Tuesday', 3: 'Wednesday', 4: 'Thursday', 5: 'Friday', 6: 'Saturday', 7: 'Sunday' } if day in Day_dict.keys(): day_of_the_week = Day_dict[day] print(day_of_the_week) Speaking.speak(self, "The day is " + day_of_the_week)
class Meaning: dic = PyDictionary() speak = Speaking() speak.speak("Which word do u want to find the meaning sir") query = speak.takeCommand() word = dic.meaning(query) print(len(word)) for states in word: print(word[states]) speak.speak("the meaning is" + str(word[states]))
class Open: speaking = Speaking() speaking.speak("Which drive do you want to open sir") take = speaking.takeCommand() if "C" in take or "c" in take: speaking.speak("Opening the C drive Sir") os.startfile("C:") elif "D" in take or "d" in take: speaking.speak("Opening the D drive Sir") os.startfile("D:") elif "E" in take or "e" in take: speaking.speak("Opening the E drive Sir") os.startfile("E:")
class GUI: speak = Speaking() root = Tk() global var var = "Listening...." root.geometry("500x500") lab = Label(root, text=var, bg="#FAB60C") lab.config(font=("Courier", 20)) var.set("User Said:") lab.pack() root.title("Year") button = Button(root, text="Press for Command", command=speak.takeCommand) button.pack() root.mainloop()
def query2(self, userhour, usermin, time_merdiem): speaking = Speaking() time = Time() date = Date() timereal = str(datetime.datetime.now()) if time_merdiem == 'p.m': if userhour == '12': userhour = '12' else: userhour = int(userhour) + 12 userhour = str(userhour) if time_merdiem == 'a.m': if userhour == '12': userhour = '00' else: pass hour = timereal[11:13] min = timereal[14:16] b = True while (b): timereal = str(datetime.datetime.now()) hour = timereal[11:13] min = timereal[14:16] # print("The userhour"+userhour) print("The alarm min " + userhour + " " + usermin) print("The current min " + hour + " " + min) if (hour != userhour or min != usermin): query = speaking.takeCommand().lower() self.all_the_queries(query) else: print("this is alarm time sir") speaking.speak("Alarm time sir") b = False
class Battery: battery = psutil.sensors_battery() speaking = Speaking() # from psutil we will import the sensors_battery class and with that we have the battery remaining while True: percent = battery.percent # print("the battery percentage is "+percent) speaking.speak("the battery percentage is " + str(percent)) notification.notify(title="Battery Percentage", message=str(percent) + "% Battery remaining", timeout=10) break time.sleep(60 * 60)
def all_the_queries(self, query): speaking = Speaking() date = Date() time = Time() if "number to english" in query: speaking.speak("what is the number sir") ans = speaking.takeCommandHindi() speaking.speak("The number is " + ans) if "list" in query: speaking.speak( "Do you know the number of elements to be added sir") query1 = speaking.takeCommand() if (query1 == 'yes'): making = Making_list() making.List_Making() else: making = Making_list() making.List_Making_Do_not_have_No() if 'number to hindi' in query: no = Number_to_Hindi() speaking.speak("tell me the number sir") number = (int)(speaking.takeCommand()) no.Numbers(number) if 'wikipedia' in query: speaking.speak("Checking in the wikipedia Sir") query = query.replace("wikipedia", "") result = wikipedia.summary(query, sentences=4) speaking.speak("According to wikipedia Sir") speaking.speak(result) elif 'set reminder' in query: self.set_Reminder() elif 'open youtube' in query: speaking.speak("Opening the youtube sir") webbrowser.open("www.youtube.com") elif 'open Google' in query: speaking.speak("Opening the google sir") webbrowser.open("google.com") elif 'open facebook' in query: speaking.speak("Opening facebook sir") webbrowser.open("facebook.com") elif 'open geeksforgeeks' in query: speaking.speak("Opening geeks for geeks sir") print("Opening geeksforgeeks Sir") webbrowser.open("geeksforgeeks.org") elif 'open the news' in query: speaking.speak("Telling about the news sir") webbrowser.open("https://www.indiatvnews.com/") # speak(webbrowser.open("https://www.indiatvnews.com/")) elif 'open online classes' in query: speaking.speak("Opening the cousresite.com sir") webbrowser.open("https://blackboard.coursesites.com/") speaking.speak("Goodluck sir for studies") elif 'time' in query: time.tellTime(counter=1) # mywindow = tk.Tk() # clock = Digital_clock(mywindow) # mywindow.mainloop() elif "bye" in query: speaking.speak("Bye sir Have a very good day sir.Take care") exit() elif "which day" in query: speaking.speak("Tell me the date sir") Date_of_the_user = speaking.takeCommand().strip() speaking.speak("Now tell me about the month sir") Month_of_User = speaking.takeCommand().lower().strip() speaking.speak("Now tell me about the year sir") Year_of_the_user = speaking.takeCommand().strip() Hello = date.No_of_odd_days_in_year(Year_of_the_user) Hello2 = date.No_of_Odd_Days_inMonths(Month_of_User, Year_of_the_user, Date_of_the_user) print(Hello2) days = (Hello2 + Hello) % 7 if (self.check_Date_validity(Date_of_the_user, Month_of_User, Year_of_the_user)): speaking.speak("According to you th date is sir" + Date_of_the_user + Month_of_User + Year_of_the_user) print("According to you th date is sir" + Date_of_the_user + Month_of_User + Year_of_the_user) self.tell_days(days) else: print("Soryy") elif 'day' in query: date.tellDay() elif 'date' in query: date.telldate() elif 'shutdown' in query: speaking.speak("So u want it sir") control() # elif "battery update" in query: # Battery() elif "Open drive" in query: Open() elif "I want to read" in query: Reading() elif "tell meaning" in query: Meaning()
def check_Date_validity(self, date, Usermonth, year): speakig = Speaking() if int(date) < 0 or int(date) > 31: print("the date is invalid sir") speakig.speak("the date is invalid sir") return False if len(year) > 4: print(len(year)) print("Invalid year sir") speakig.speak("Invalid year sir") return False list_Month = { 'january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december' } if Usermonth not in list_Month: print("Invalid Month sir") speakig.speak("The month that you have given is invalid sir") return False if Usermonth == 'february': if int(year) % 4 == 0 and int(year) % 400 == 0 and int(date) > 29: return False speakig.speak("Invalid year Sir") elif int(date) > 28: speakig.speak("Invalid year Sir") return False else: return True
def List_Making_Do_not_have_No(self): speaking = Speaking() speaking.speak("Tell me the elements sir") i = 0 list1 = [] while (True): query = speaking.takeCommand() list1.append(i + 1) list1.append(query) speaking.speak((str)(i + 1) + "Element is " + query) speaking.speak("do you want to stop adding sir") query1 = speaking.takeCommand() i = i + 1 print("the list=", list1) if (query1 == 'yes'): speaking.speak("the final list is sir" + str(list1)) df = pd.DataFrame(list1) df.to_csv('filename.csv', index=False) speaking.speak( "Thank you for making the list with help of me sir and I converting the list to csv file sir" ) speaking.speak( "Do you want to know the number of elements in the list sir" ) take = speaking.takeCommand() if (take == 'yes'): speaking.speak(list1[(list1.__len__()) - 2]) print(list1.__len__()) else: speaking.speak("thank you sir") break else: speaking.speak("The next element is sir") continue
def songs(self): Speaking.speak(self, "the reminder that u said is now sir") music = 'D:\\Music' songs = os.listdir(music) os.startfile(os.path.join(music, songs[0]))