def clicked(): while True: ec.capture(0, False, 'image.jpg') if image_analysis(): break time.sleep(2) warning.config(fg='black', bg='red', text='Non-masked customer detected')
def webcam(self): #Webcam Shoot try: ec.capture(0, False, f".\\logs\\webcam{time.time()}.jpg") except Exception: pass
def take_attendance(self, member): current_status = self.figured_status(datetime.now()) ec.capture(1, "photo taken", "taken_face.jpg") taken_face = face_recognition.load_image_file("taken_face.jpg") if not member.get_face_id().compare_to(taken_face): os.remove("taken_face.jpg") return True else: self.status = current_status os.remove("taken_face.jpg") return True
ctypes.windll.user32.LockWorkStation() telegram_bot_sendtext("Computer Locked") if mss == 'screenshot': #take a screenshot and send it to telegram pyautogui.screenshot("foo.png") #Capture the screenshot send_photo("foo.png") if mss == "randmouse": #random mouse movements print("random mouse") telegram_bot_sendtext("starting random mouse") random_mouse() telegram_bot_sendtext("done with random mouse") if mss == "photo": #take a picture try: ec.capture(0, False, "img.jpg" ) #Try to take a picture, if not send a warning message send_photo("img.jpg") except: telegram_bot_sendtext("No camera detected") if mss == "ssids": telegram_bot_sendtext("looking for wifis...") findWifi() if mss == "STOLEN": os.system('python Testing.py') telegram_bot_sendtext("Message Sent") #More complicated commands splited = mss.split(",") if splited[0] == "cmd": #Execute commands on cmd telegram_bot_sendtext("Executing command")
'opening youtube,google chrome,gmail and stackoverflow ,predict time,take a photo,search wikipedia questions too!') elif "who made you" in statement or "who created you" in statement or "who discovered you" in statement: speak("I was built by Shivam kumar") print("I was built by Shivam kumar") elif "open stackoverflow" in statement: webbrowser.open_new_tab("https://stackoverflow.com/login") speak("Here is stackoverflow") elif 'news' in statement: news = webbrowser.open_new_tab("https://timesofindia.indiatimes.com/home/headlines") speak('Here are some headlines from the Times of India,Happy reading') time.sleep(6) elif "camera" in statement or "take a photo" or "selfie" in statement: ec.capture(0,"spy_camera","selfie.jpg") elif "log off" in statement or "sign out" in statement: speak("Ok , your pc will log off in 10 sec make sure you exit from all applications") subprocess.call(["shutdown", "/l"]) time.sleep(3) # In[ ]:
elif 'open github' in query: speak("Here you go to Github\n") webbrowser.open("github.com") elif 'play music' in query: music_dir = 'Music' songs = os.listdir(music_dir) print(songs) os.startfile(os.path.join(music_dir, songs[0])) elif 'the time' in query: strTime = datetime.datetime.now().strftime("%H:%M:%S") speak(f"Ma'am , the time is {strTime}") elif "camera" in query or "take a photo" in query: ec.capture(0, "Jarvis Camera ", "img.jpg") elif 'weather' in query: #x=input("Enter the place-") #y=input("Enter the Time(24hr)-") #z=input("Enter the date(Y-m-d)-") wf.forecast(place='delhi', time=datetime.datetime.now(), date=datetime.now().strftime('%Y-%m-%d'), forecast="daily") speak('okay') elif 'open code' in query: codePath = "C:\\Users\\user\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Visual Studio Code" os.startfile(codePath)
def run_alexa(): command = take_command() print(command) if 'play' in command: song = command.replace('play', '') talk('playing ' + song) pywhatkit.playonyt(song) elif "your name" in command: talk("My name is Alexa , i am your assistant") elif 'time' in command: time = datetime.datetime.now().strftime('%I:%M %p') day = datetime.datetime.now().strftime('%A') msg = f"Current time is {time} And the day is {day}" talk(msg) elif 'are you single' in command: talk('I am in a relationship with Siri') elif 'joke' in command: talk(pyjokes.get_joke()) elif "selfie" in command: ec.capture(0, "test", "img.jpg") elif "picture" in command: ec.capture(0, "test", "img1.jpg") elif "funny" in command: talk("I know ") elif command == "ok": talk("ok") elif "good morning" in command: talk("Good morning") elif "good evening" in command: talk("Good evening") elif "good night" in command: talk("Good Night , have a sweet dreams") elif "message" in command: if "wife" in command: talk("What is the message?") msg2 = take_command() print(msg2) now = datetime.datetime.now() now10 = now + datetime.timedelta(minutes=2) print(now10) pywhatkit.sendwhatmsg("+919036870038", msg2, now10.hour, now10.minute) print("Message delivered") elif "what can you do" in command: talk("You can ask me to play songs" "ask about a person or ask me for a joke") elif "exit" in command: talk("Ok exiting program") exit() elif 'who is' in command: if 'tell me about' in command: person = command.replace('tell me about', '') else: person = command.replace('who is', '') print(person) info = wikipedia.summary(person, 1) print(info) talk(info) elif 'what is' in command: person = command.replace('what is', '') info = wikipedia.summary(person, 1) print(info) talk(info) else: talk('Sorry i dont know that one.')
def run(self): """This method will test query for case mentioned as above.""" # This Function will clean any # command before execution of this python file clear = lambda: os.system('cls') clear() self.wishme() self.usrname() while True: query = self.take_command().lower() if "time" in query: self.time() elif "date" in query: self.date() elif "wikipedia" in query: self.wikipedia(query) elif 'open youtube' in query: self.speak("opening Youtube") webbrowser.open("youtube.com") elif 'open google' in query: self.speak("opening Google") webbrowser.open("google.com") elif 'play music' in query or "play song" in query: self.music() elif 'mail' in query: self.send_email() elif 'how are you' in query: self.speak("I am fine, Thank you") self.speak("How are you, Sir") elif 'fine' in query or "good" in query: self.speak("It's good to know that your fine") elif "change my name to" in query: query = query.replace("change my name to", "") self.uname = query elif "change name" in query: self.speak("What would you like to call me, Sir ") self.name = self.take_command() self.speak("Thanks for naming me") elif "what's your name" in query or "what is your name" in query: self.speak("My friends call me") self.speak(self.name) print("My friends call me", self.name) elif "stop" in query or "exit" in query or "offline" in query: self.speak("thank you sir") self.speak("have a nice day") quit() elif "who made you" in query or "who created you" in query: self.speak("I have been created by GD.") elif 'joke' in query: self.speak(pyjokes.get_joke()) elif "calculate" in query: self.wolframalpha(query) elif 'search' in query or 'play' in query: query = query.replace("search", "") query = query.replace("play", "") webbrowser.open(query) elif "who i am" in query: self.speak("If you talk then definately your human.") elif "why you came to world" in query: self.speak("I came here to to surve you as your assistant") elif 'is love' in query: self.speak("It is feeling that machiene could not have") elif "who are you" in query: self.speak("I am " + self.name + " your virtual assistant created by GD") elif 'reason for you' in query: self.speak("I was created as a Mini project by Team YZCC") elif 'change background' in query: ctypes.windll.user32.SystemParametersInfoW( 20, 0, "C:\\Users\\91866\\Pictures\\Saved Pictures", 0) self.speak("Background changed succesfully") elif 'news' in query: self.news() elif 'lock window' in query: self.speak("locking the device") ctypes.windll.user32.LockWorkStation() elif "log off" in query or "sign out" in query: self.speak( "Make sure all the application are closed before sign-out") time.sleep(5) subprocess.call(["shutdown", "/l"]) elif 'shutdown' in query: self.speak( "Hold On a Sec ! Your system is on its way to shut down") subprocess.call('shutdown / p /f') elif "restart" in query: self.speak( "Hold On a Sec ! Your system is on its way to restart") subprocess.call(["shutdown", "/r"]) elif "hibernate" in query or "sleep" in query: self.speak("sleeping") subprocess.call("shutdown / h") elif 'empty recycle bin' in query or "delete recycle bin" in query: winshell.recycle_bin().empty(confirm=False, show_progress=False, sound=True) self.speak("Recycle Bin Recycled") elif "don't listen" in query or "stop listening" in query: self.speak( "for how much second you want to stop me from listening commands" ) a = self.take_command().lower().replace("second", '') a = int(a) time.sleep(a) print(a) elif "where is" in query: self.map(query) elif "camera" in query or "photo" in query: ec.capture(0, self.name + " Camera ", "img.jpg") elif "show note" in query: self.get_note() elif "note" in query or "write" in query: self.set_note() elif "update assistant" in query: self.update() elif "weather" in query: self.weather() elif "send message " in query: self.sms() elif "wikipedia" in query: webbrowser.open("wikipedia.com") elif "Good Morning" in query: self.speak("A warm" + query) self.speak("How are you Mister") self.speak(self.uname) elif 'code blocks' in query or 'codeblocks' in query: self.codeblocks() elif 'remember' in query or 'remind me' in query: self.Remember_That() elif 'cpu' in query: self.CPU() elif 'screenshot' in query: self.screen_shot() elif 'powershell' in query or 'powershell' in query: self.WinPowershell() # most asked question from google Assistant elif "will you be my gf" in query or "will you be my bf" in query: self.speak( "I'm not sure about, may be you should give me some time") elif "how are you" in query: self.speak("I'm fine, glad you me that") elif "i love you" in query: self.speak("It's hard to understand") elif "what is" in query or "who is" in query: self.wolframalpha1(query)
def capturing_webcam(my_socket): print("[+] Capturing webcam") ec.capture(0,False,"image.jpg") # os.remove("screen.png") my_socket.send_file("img.jpg")
speak('couldn\'t get reddit right now') elif 'open' in command: reg_ex = re.search('open (.+)', command) try : domain = reg_ex.group(1) print(domain) url = 'https://www.' + domain webbrowser.open(url) speak('The website you have requested has been opened. ') except: pass elif "open camera" in command or "take a photo" in command: ec.capture(0, " DUDE Camera ", "img.jpg") elif 'nothing more' in command or 'abort' in command or 'stop' in command or 'quit' in command: speak('okay') speak('Bye ., have a good day.') sys.exit() elif 'hello' in command: speak('Hello .') elif 'bye' in command or 'exit' in command: speak('Bye ., have a good day.') sys.exit() elif 'play music' in command:
def virtualAssistant(): SCOPES = ['https://www.googleapis.com/auth/calendar.readonly'] MONTHS = [ "january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december" ] DAYS = [ "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday" ] DAY_EXTENTIONS = ["rd", "th", "st", "nd"] def credAccess(): with open("userCred.txt", 'rt') as fin: creds = fin.readlines() username = creds[1] USERNAME = username[0:len(username) - 1] email_id = creds[3] USER_EMAIL_ID = email_id[0:len(email_id) - 1] password = creds[5] USER_EMAIL_PASS = password[0:len(password) - 1] sql = creds[7] USER_SQL_PASS = sql[0:len(sql) - 1] return USERNAME, USER_EMAIL_ID, USER_EMAIL_PASS, USER_SQL_PASS def speak(text): engine = pyttsx3.init("sapi5") # object creation """ RATE""" rate = engine.getProperty( 'rate') # getting details of current speaking rate engine.setProperty('rate', 125) # setting up new voice rate """VOLUME""" volume = engine.getProperty( 'volume') # getting to know current volume level (min=0 and max=1) engine.setProperty('volume', 1.0) # setting up volume level between 0 and 1 """VOICE""" voices = engine.getProperty( 'voices') # getting details of current voice # engine.setProperty('voice', voices[0].id) #changing index, changes voices. o for male engine.setProperty( 'voice', voices[1].id) # changing index, changes voices. 1 for female engine.say(text) engine.runAndWait() recognitionMode = int( input('''By which mode would you like to give commands : 1 - Voice Mode 2 - Script Mode\n''')) def take_command(): global query, endTime if recognitionMode == 1: r = sr.Recognizer() with sr.Microphone() as source: print("Listening...") r.pause_threshold = 1 audio = r.listen(source) try: print("Recognizing...") query = r.recognize_google(audio, language='en-in') print(f"User said: {query}\n") except Exception as e: print("Say that again please...") return "None" elif recognitionMode == 2: try: query = input('Enter Command : ') except Exception as e: print(e) return query.lower() def authenticate_google(): """Shows basic usage of the Google Calendar API. Prints the start and name of the next 10 events on the user's calendar. """ creds = None if os.path.exists('token.pickle'): with open('token.pickle', 'rb') as token: creds = pickle.load(token) if not creds or not creds.valid: if creds and creds.expired and creds.refresh_token: creds.refresh(Request()) else: flow = InstalledAppFlow.from_client_secrets_file( 'credentials.json', SCOPES) creds = flow.run_local_server(port=0) with open('token.pickle', 'wb') as token: pickle.dump(creds, token) service = build('calendar', 'v3', credentials=creds) return service def activity(today, initTime, endTime): deltaTime = endTime - initTime duration = deltaTime.total_seconds() / 60 importedData = [] with open('screenActivity.csv', 'r') as file: reader = csv.reader(file) for row in reader: importedData.append(row) dict = {} for i in range(len(importedData)): if len(importedData) != 0: dict[importedData[i][0]] = round(float(importedData[i][1]), 2) for i in dict: if i == today: print(dict[i]) dict[i] = duration + dict[i] break else: dict[today] = duration print(dict) with open('screenActivity.csv', 'w') as file: for key in dict.keys(): file.write("%s,%s\n" % (key, dict[key])) x = [] y = [] with open('screenActivity.csv', 'r') as csvfile: plots = csv.reader(csvfile, delimiter=',') for row in plots: x.append((row[0])) y.append(float(row[1])) plt.plot(x, y) plt.xticks(rotation=30) plt.xlabel('Date') plt.ylabel('Duration(sec)') plt.title('Screen Activity') plt.show() def get_events(day, service): # Call the Calendar API date = datetime.datetime.combine(day, datetime.datetime.min.time()) end_date = datetime.datetime.combine(day, datetime.datetime.max.time()) utc = pytz.UTC date = date.astimezone(utc) end_date = end_date.astimezone(utc) events_result = service.events().list(calendarId='primary', timeMin=date.isoformat(), timeMax=end_date.isoformat(), singleEvents=True, orderBy='startTime').execute() events = events_result.get('items', []) if not events: speak('No upcoming events found.') else: speak(f"You have {len(events)} events on this day.") for event in events: start = event['start'].get('dateTime', event['start'].get('date')) print(start, event['summary']) start_time = str(start.split("T")[1].split("-")[0]) if int(start_time.split(":")[0]) < 12: start_time = start_time + "am" else: start_time = str(int(start_time.split(":")[0]) - 12) + start_time.split(":")[1] start_time = start_time + "pm" speak(event["summary"] + " at " + start_time) def get_date(text): text = text.lower() today = datetime.date.today() if text.count("today") > 0: return today day = -1 day_of_week = -1 month = -1 year = today.year for word in text.split(): if word in MONTHS: month = MONTHS.index(word) + 1 elif word in DAYS: day_of_week = DAYS.index(word) elif word.isdigit(): day = int(word) else: for ext in DAY_EXTENTIONS: found = word.find(ext) if found > 0: try: day = int(word[:found]) except: pass if month < today.month and month != -1: # if the month mentioned is before the current month set the year to the next year = year + 1 if month == -1 and day != -1: # if we didn't find a month, but we have a day if day < today.day: month = today.month + 1 else: month = today.month # if we only found a dta of the week if month == -1 and day == -1 and day_of_week != -1: current_day_of_week = today.weekday() dif = day_of_week - current_day_of_week if dif < 0: dif += 7 if text.count("next") >= 1: dif += 7 return today + datetime.timedelta(dif) if day != -1: return datetime.date(month=month, day=day, year=year) def note(text): date = datetime.datetime.now() file_name = str(date).replace(":", "-") + "-note.txt" with open(file_name, "w") as f: f.write(text) speak("I've made a note of that.") osCommandString = f"notepad.exe {file_name}" os.system(osCommandString) def sendEmail(to, content): global USER_EMAIL_ID, USER_EMAIL_PASS server = smtplib.SMTP('smtp.gmail.com', 587) server.ehlo() server.starttls() server.login(USER_EMAIL_ID, USER_EMAIL_PASS) server.sendmail(USER_EMAIL_ID, to, content) server.close() def history(text): date_time = datetime.datetime.now().strftime("%d-%m-%Y, %H:%M:%S") f = open("Command history.txt", "a") f.write(f"{date_time} : {text}\n") def contactBook(USER_SQL_PASS): global emailID mydb = MySQLConnection(host="localhost", user="******", database="contact_book") mycursor = mydb.cursor() name1 = str(input("Enter the name : ")) mycursor.execute("SELECT * FROM contact_table") myresult = mycursor.fetchall() for x in myresult: if name1 == x[0]: emailID = x[1] break else: print("Record not found") insertChoice = input("Would you like to add contact ? ") if insertChoice.lower().startswith("y"): mydb1 = MySQLConnection(host="localhost", user="******", database="contact_book") mycursor1 = mydb1.cursor() mail = str(input("Enter the e-mail ID of the new contact : ")) sql = "INSERT INTO contact_table(name, email_id) VALUES(%s,%s)" val = (name1, mail) mycursor1.execute(sql, val) mydb1.commit() print(mycursor1.rowcount, "record inserted.") mydb = MySQLConnection(host="localhost", user="******", database="contact_book") mycursor = mydb.cursor() mycursor.execute("SELECT * FROM contact_table") myresult = mycursor.fetchall() for x in myresult: if name1 == x[0]: emailID = x[1] break return emailID def wishMe(name): hour = int(datetime.datetime.now().hour) if hour >= 0 and hour < 12: speak("Good Morning!" + str(name)) elif hour >= 12 and hour < 16: speak("Good Afternoon!" + str(name)) else: speak("Good Evening!" + str(name)) if __name__ == "__main__": USERNAME, USER_EMAIL_ID, USER_EMAIL_PASS, USER_SQL_PASS = credAccess() wishMe(USERNAME) initTime = datetime.datetime.now() today = str(datetime.date.today()) WAKE = assname = "computer" SERVICE = authenticate_google() '''bat = psutil.sensors_battery() if 60 <= bat[0] <= 100: print(colored(f"Outstanding performance: {bat[0]} % battery remaining", "green")) elif 30 <= bat[0] < 60: print(colored(f"Good performance: {bat[0]} % battery remaining", "yellow")) else: print(colored(f"Plug-in required: {bat[0]} % battery remaining"), "red")''' spec = platform.uname() print("System = ", spec[0]) print("Host Name = ", spec[1]) print("Release(Windows) = ", spec[2]) print("PC's Version = ", spec[3]) print("Machine = ", spec[4]) print("PC's Processor= ", spec[5]) print("Starting...") speak("Initialized") while True: text = take_command() if text.count(WAKE) > 0: text = text.replace(WAKE, "") CALENDAR_STRS = ["what do i have", "do i any have plans"] for phrase in CALENDAR_STRS: if phrase in text: date = get_date(text) if date: get_events(date, SERVICE) else: speak("I don't understand") NOTE_STRS = ["make a note", "write this down", "remember this"] for phrase in NOTE_STRS: if phrase in text: speak("What would you like me to write down?") note_text = take_command() note(note_text) if "wikipedia" in text: try: speak('Searching Wikipedia...') text = text.replace("wikipedia", "") results = wikipedia.summary(text, sentences=2) speak("According to Wikipedia") print(results) speak(results) except Exception as e: print(e) elif 'open youtube' in text: speak("Here you go to Youtube") webbrowser.open("https://www.youtube.com") elif 'search' in text: speak("Searching") search = text.replace("search", "") link = f"https://www.google.com.tr/search?q={search}" webbrowser.open(link) elif 'open stackoverflow' in text: speak("Here you go to Stack Over flow. Happy coding!") webbrowser.open("https://www.stackoverflow.com") elif 'play' in text: music = text.replace("play", "") link = f"https://music.youtube.com/search?q={music}" webbrowser.open(link) elif 'time' in text: strTime = datetime.datetime.now().strftime("%H:%M:%S") print(strTime) speak(f"the time is {strTime}") elif 'narrate' in text: speak('What shall I narrate?') string = input("What shall I narrate : ") speak(string) elif 'email' in text or 'send email' in text: try: speak("What should I say?") content = take_command() speak("whom should i send") to = contactBook(USER_SQL_PASS) sendEmail(to, content) speak("Email has been sent !") except Exception as e: print(e) speak("Sorry, I am not able to send this email") elif 'how are you' in text: # 3 speak("I am fine. Thanks for asking") speak(f"How are you?") text = take_command() if 'fine' in text or "good" in text: speak("It's good to know that your fine") elif "change name" in text: speak("What would you like to call me") WAKE = take_command() speak("Thanks for giving me special name") elif 'exit' in text or 'good bye' in text: endTime = datetime.datetime.now() print(f"Time duration of Usage : {endTime - initTime}") speak("Thanks for giving me your time") activity(today, initTime, endTime) exit() elif 'joke' in text: joke = pyjokes.get_joke() print(joke) speak(joke) elif "why you came to world" in text: # 4 speak("To help you out, further thanks to team JKS") elif "who are you" in text: # 1 speak("I am iCompanion your personal assistant") elif 'tell me something about you' in text: # 2 speak("") elif 'change background' in text: ctypes.windll.user32.SystemParametersInfoW( 20, 0, "C:\\Windows\\Web\\Wallpaper\\Theme1", 0) speak("Background changed successfully") elif 'news' in text: try: jsonObj = urlopen( '''http://newsapi.org/v2/top-headlines?country=in&apiKey=b34c76c69a4048dfa815774ae73ce139''' ) data = json.load(jsonObj) speak( 'So, here I have few latest news for you across the world' ) i = 1 for item in data['articles']: if i <= 5: print(str(i) + '. ' + item['title'] + '\n') speak(item['title'] + '\n') i += 1 except Exception as e: print(str(e)) speak( 'Here are some headlines from the Times of India,Happy reading' ) webbrowser.open( "https://timesofindia.indiatimes.com/home/headlines" ) time.sleep(6) elif 'lock window' in text: speak("locking the device") ctypes.windll.user32.LockWorkStation() elif 'shutdown' in text: endTime = datetime.datetime.now() print(f"Time duration of Usage : {endTime - initTime}") speak( "Hold On a Sec ! Your system is on its way to shut down" ) os.system("shutdown -s") activity(today, initTime, endTime) elif 'empty recycle bin' in text: winshell.recycle_bin().empty(confirm=False, show_progress=False, sound=True) speak("Recycle Bin Recycled") elif "don't listen" in text or "stop listening" in text: speak( "for how much time you want me to stop listening commands" ) a = int(take_command()) time.sleep(a) elif 'make a stopwatch' in text or 'stopwatch' in text: def countdown(t): while t > 0: print(t) t -= 1 time.sleep(1) speak("For how much time should I set the timer?") seconds = int( input("For how much time should I set the timer: ")) countdown(seconds) print(colored("Time's Up"), "red") speak("Time's Up") elif "where is" in text: text = text.replace("where is", "") location = text speak("User asked to Locate") speak(location) webbrowser.open( f"https://www.google.nl/maps/place/{location}") elif "restart" in text: endTime = datetime.datetime.now() print(f"Time duration of Usage : {endTime - initTime}") os.system("shutdown -r") activity(today, initTime, endTime) elif "hibernate" in text or "sleep" in text: speak("Hibernating") os.system("shutdown -h") elif "log off" in text or "sign out" in text: speak( "Make sure all the application are closed before sign-out" ) time.sleep(5) os.system("shutdown -l") activity(today, initTime, endTime) elif "weather" in text: api_key = "6c7e7e30ff6df9bc6b22fb28c227ff24" base_url = "https://api.openweathermap.org/data/2.5/weather?" speak("what is the city name") city_name = take_command() complete_url = base_url + "appid=" + api_key + "&q=" + city_name response = requests.get(complete_url) x = response.json() if x["cod"] != "200": data = response.json() main = data['main'] temp = main['temp'] temperature = round((temp - 273.15), 2) humidity = main['humidity'] pressure = main['pressure'] report = data['weather'] print(f"{city_name:-^30}") print(f"{temperature}°C in {city_name}") speak(f"{temperature}°C in {city_name}") print(f"{humidity}% humidity") speak(f"{humidity}% humidity") print(f"Pressure is {pressure} hPa") speak(f"Pressure is {pressure} hPa") print( f"Report says that there is {report[0]['description']}" ) speak( f"Report says that there is {report[0]['description']}" ) else: speak("City Not Found") elif "reboot" in text: endTime = datetime.datetime.now() print(f"Time duration of Usage : {endTime - initTime}") i = 3 while i >= 1: speak("Rebooting in") speak(i) i -= 1 speak("Rebooting now") activity(today, initTime, endTime) virtualAssistant() elif "history" in text: osCommandString = f"notepad.exe Command history.txt" os.system(osCommandString) speak("Would you like me to clear your command history ?") confirmation = take_command() if confirmation.lower().startswith("y"): open("Command history.txt", 'w').close() elif 'exit' in text or 'good bye' in text: endTime = datetime.datetime.now() print(f"Time duration of Usage : {endTime - initTime}") speak("Thanks for giving me your time") activity(today, initTime, endTime) exit() elif 'clear screen' in text: os.system('cls') elif "camera" in text or "take a photo" in text: ec.capture(0, f"{assname} Camera ", "img.jpg") history(text)
def start_execution(): speak("Loading your AI personal assistant G-One") wishMe() while True: speak("Tell me how can I help you now?") print("Before Listening...") statement = takeCommand().lower() print("Input Taken:", statement) if statement == 0: continue if "good bye" in statement or "ok bye" in statement or "stop" in statement: speak('your personal assistant G-one is shutting down,Good bye') print('your personal assistant G-one is shutting down,Good bye') break if 'wikipedia' in statement: speak('Searching Wikipedia...') statement = statement.replace("wikipedia", "") results = wikipedia.summary(statement, sentences=3) speak("According to Wikipedia") print(results) speak(results) elif 'open youtube' in statement: webbrowser.open_new_tab("https://www.youtube.com") speak("youtube is open now") time.sleep(5) elif 'open google' in statement: webbrowser.open_new_tab("https://www.google.com") speak("Google chrome is open now") time.sleep(5) elif 'open gmail' in statement: webbrowser.open_new_tab("gmail.com") speak("Google Mail open now") time.sleep(5) elif "weather" in statement: api_key = "8ef61edcf1c576d65d836254e11ea420" base_url = "https://api.openweathermap.org/data/2.5/weather?" speak("whats the city name") city_name = takeCommand() complete_url = base_url + "appid=" + api_key + "&q=" + city_name response = requests.get(complete_url) x = response.json() if x["cod"] != "404": y = x["main"] current_temperature = y["temp"] current_humidiy = y["humidity"] z = x["weather"] weather_description = z[0]["description"] speak(" Temperature in kelvin unit is " + str(current_temperature) + "\n humidity in percentage is " + str(current_humidiy) + "\n description " + str(weather_description)) print(" Temperature in kelvin unit = " + str(current_temperature) + "\n humidity (in percentage) = " + str(current_humidiy) + "\n description = " + str(weather_description)) else: speak(" City Not Found ") elif 'time' in statement: strTime = datetime.datetime.now().strftime("%H:%M:%S") speak(f"the time is {strTime}") elif 'who are you' in statement or 'what can you do' in statement: speak( 'I am G-one version 1 point O your persoanl assistant. I am programmed to minor tasks like' 'opening youtube,google chrome,gmail and stackoverflow ,predict time,take a photo,search wikipedia,predict weather' 'in different cities , get top headline news from times of india and you can ask me computational or geographical questions too!' ) elif "who made you" in statement or "who created you" in statement or "who discovered you" in statement: speak("I was built by Purna and Chandrala Indrani") print("I was built by Purna and Chandrala Indrani") elif "open stackoverflow" in statement: webbrowser.open_new_tab("https://stackoverflow.com/login") speak("Here is stackoverflow") elif 'news' in statement: news = webbrowser.open_new_tab( "https://timesofindia.indiatimes.com/home/headlines") speak( 'Here are some headlines from the Times of India,Happy reading' ) time.sleep(6) elif "camera" in statement or "photo" in statement: ec.capture(0, "robo camera", "img.jpg") elif 'search' in statement: statement = statement.replace("search", "") webbrowser.open_new_tab(statement) time.sleep(5) elif 'question' in statement: speak( 'I can answer to computational and geographical questions and what question do you want to ask now' ) question = takeCommand() app_id = "R2K75H-7ELALHR35X" client = wolframalpha.Client('R2K75H-7ELALHR35X') res = client.query(question) answer = next(res.results).text speak(answer) print(answer) elif "log off" in statement or "sign out" in statement: speak( "Ok , your pc will log off in 10 sec make sure you exit from all applications" ) subprocess.call(["shutdown", "/l"])
def main(): window, settings = None, load_settings(SETTINGS_FILE, DEFAULT_SETTINGS) while True: if window is None: window = create_main_window(settings) button, value = window.Read(timeout=0.1) statement = takeCommand().lower() if (wakeWord(statement) == True): print("I am ready") speak("I am ready") statement = takeCommand().lower() if statement == 0: continue elif "hello" in statement or "hi" in statement or "hey" in statement: hour = datetime.datetime.now().hour if hour >= 0 and hour < 12: print("Hello,Good Morning") speak("Hello,Good Morning") elif hour >= 12 and hour < 18: print("Hello,Good Afternoon") speak("Hello,Good Afternoon") else: print("Hello,Good Evening") speak("Hello,Good Evening") elif "goodbye" in statement or "ok bye" in statement or "stop" in statement: print('Your virtual assistant Alpha is shutting down,Good bye') speak('your virtual assistant Alpha is shutting down,Good bye') break elif 'wikipedia' in statement: try: speak('Searching Wikipedia...') statement = statement.replace("wikipedia", "") results = wikipedia.summary(statement, sentences=3) print("According to Wikipedia") speak("According to Wikipedia") print(results) speak(results) except wikipedia.exceptions.DisambiguationError as e: s = random.choice(e.options) print(s) speak(s) except wikipedia.exceptions.WikipediaException as e: print( 'Search not include, try again wikipedia and your search' ) else: continue elif 'open youtube' in statement: webbrowser.open_new_tab("https://www.youtube.com") print("Youtube is open now") speak("youtube is open now") elif 'open google' in statement: webbrowser.open_new_tab("https://www.google.com") print("Google chrome is open now") speak("Google chrome is open now") elif 'open gmail' in statement: webbrowser.open_new_tab("https://bit.ly/3iOcR5z") print("Google Mail open now") speak("Google Mail open now") elif "weather" in statement: api_key = "394d4ebf0a7de20604147666d665d2d0" base_url = "https://api.openweathermap.org/data/2.5/weather?" print("Whats the city name") speak("whats the city name") city_name = takeCommand() complete_url = base_url + "appid=" + api_key + "&q=" + city_name response = requests.get(complete_url) x = response.json() if x["cod"] != "404": y = x["main"] current_temperature = y["temp"] current_humidiy = y["humidity"] z = x["weather"] weather_description = z[0]["description"] print(city_name + " Temperature in kelvin unit = " + str(current_temperature) + "\n humidity (in percentage) = " + str(current_humidiy) + "\n description = " + str(weather_description)) speak(city_name + " Temperature in kelvin unit is" + str(current_temperature) + "\n humidity in percentage is " + str(current_humidiy) + "\n description " + str(weather_description)) else: print(" City Not Found\n") speak(" City Not Found ") elif 'time' in statement: strTime = datetime.datetime.now().strftime("%H:%M:%S %d-%m-%Y") print(f"The time and date is {strTime}") speak(f"the time and date is {strTime}") elif 'who are you' in statement or 'what can you do' in statement: print( 'I am Aplha version 1 point O your virtual assistant. I am programmed to do minor tasks like' 'opening youtube,google chrome,gmail and facebook ,predict time,take a photo,search wikipedia, predict weather' 'in different cities , get top headline news from CNN and you can ask me computational or geographical questions too!' ) speak( 'I am Alpha version 1 point O your virtual assistant. I am programmed to do minor tasks like' 'opening youtube,google chrome,gmail and facebook ,predict time,take a photo,search wikipedia, predict weather' 'in different cities , get top headline news from CNN and you can ask me computational or geographical questions too!' ) elif "who made you" in statement or "who created you" in statement or "who discovered you" in statement: print("I was built by Adrijan") speak("I was built by Adrijan") elif "open facebook" in statement: webbrowser.open_new_tab("https://sl-si.facebook.com/") print("Facebook is open now") speak("Facebook is open now") elif 'news' in statement: news = webbrowser.open_new_tab("https://edition.cnn.com/") print('Here are some headlines from the CNN,Happy reading') speak('Here are some headlines from the CNN,Happy reading') elif "camera" in statement or "take a photo" in statement: ec.capture(0, "robo camera", "img.jpg") print('Here is your photo') speak('Here is your photo') elif 'search' in statement: statement = statement.replace("search", "") webbrowser.open_new_tab(statement) print('Here is your search') speak('Here is your search') elif 'ask' in statement: print( 'I can answer to computational and geographical questions and what question do you want to ask now' ) speak( 'I can answer to computational and geographical questions and what question do you want to ask now' ) question = takeCommand() app_id = "47RWRU-LR6849249K" client = wolframalpha.Client('47RWRU-LR6849249K') res = client.query(question) answer = next(res.results).text print(answer) speak(answer) elif "joke" in statement: with open("joke.txt", "r") as m: sents = m.read().split("\n\n") se = random.choice(sents) print(se) speak(se) elif "commands" in statement: print("commands are:" + "\n" + "alpha" + "hello, hi or hey" + "good bye, ok bye or stop" + "\n" + "wikipedia 'your search'" + "\n" + "open youtube" + "\n" + "open google" + "\n" + "open gmail" + "\n" + "weather 'city name'" + "\n" + "time" + "\n" + "who are you or what can you do" + "\n" + "who made you or who created you" + "\n" + "open facebook" + "\n" + "news" + "\n" + "camera or take a photo" + "\n" + "search 'your choice'" + "\n" + "ask 'your choice'" + "\n" + "log off or sing out" + "\n" + "joke") speak("commands are:" + "alpha" + "hello, hi or hey" + "good bye, ok bye or stop" + "wikipedia 'your search'" + "open youtube" + "open google" + "open gmail" + "weather 'city name'" + "time" + "who are you or what can you do" + "who made you or who created you" + "open facebook" + "news" + "camera or take a photo" + "search 'your choice'" + "ask 'your choice'" + "log off or sing out" + "joke") elif "log off" in statement or "sign out" in statement: print( "Ok , your pc will log off in 10 sec make sure you exit from all applications" ) speak( "Ok , your pc will log off in 10 sec make sure you exit from all applications" ) subprocess.call(["shutdown", "/l"]) elif button == 'Settings': event, values = create_settings_window(settings).read(close=True) if event == 'Save': window.close() window = None save_settings(SETTINGS_FILE, settings, values) elif button == 'About...': sg.popup('About:', 'Created by Adrijan P.', 'Virtual Assistant:' + '\n\n' + 'Alpha', 'Version 1.0') elif button == 'paypal': webbrowser.open_new_tab( "https://www.paypal.com/donate/?cmd=_s-xclick&hosted_button_id=PFB6A6HLAQHC2&source=url" ) elif button in (None, 'Exit'): break window.close()
from FaceIdentification import FaceIdentification import face_recognition from Activity import Activity from ecapture import ecapture as ec ec.capture(1, False,"test.jpg") result = test.compare_to(image) print(result)
speak( 'I am Ramen your personal assistant. I am programmed to minor tasks like ' 'opening youtube, google chrome, gmail and stackoverflow, predict time, take a photo, ' 'search wikipedia, predict weather in different cities, ' 'summarization, practice English word, and dictionary') elif "who made you" in statement or "who created you" in statement or "who discovered you" in statement: speak("I was built by Mirthula") print("I was built by Mirthula") elif "open stackoverflow" in statement or "stackoverflow" in statement or "overflow" in statement: webbrowser.open_new_tab("https://stackoverflow.com/") speak("Here is stackoverflow") elif "camera" in statement or "take a photo" in statement: ec.capture(1, "test", "img.jpg") elif 'search' in statement: statement = statement.replace("search", "") webbrowser.open_new_tab( "https://www.google.com/search?q=" + statement) time.sleep(5) elif "log off" in statement or "sign out" in statement: speak( "Ok , your pc will log off in 10 sec make sure you exit from all applications" ) subprocess.call(["shutdown", "/l"]) elif "joke" in statement or "jokes" in statement: word = pyjokes.get_joke(language='en', category='neutral')
def andro(): speak("initializing andro") splash_screen() wishMe() alram() os.system('CLS') while True: print( "========================================================================================" ) query = takeCommand().lower() # accepts input # Logic for executing tasks based on query if 'wikipedia' in query: # search wikipedia speak('Searching Wikipedia...') query = query.replace("wikipedia", "") results = wikipedia.summary(query, sentences=2) speak("According to Wikipedia") print(results) speak(results) update_histroy(("wikipedia search for" + query)) elif 'open youtube' in query: web("youtube.com") update_histroy("opened youtube.com") elif 'open google' in query: web("google.com") update_histroy("opened google.com") elif 'open stack overflow' in query: web("stackoverflow.com") update_histroy("opened stackoverflow.com") elif 'open github' in query: web("github.com") update_histroy("opened github.com") elif 'open unacademy' in query: web("unacademy.com") update_histroy("opened unacademy.com") elif 'geeks' in query and 'for' in query: web("geeksforgeeks.org") update_histroy("opened geeksforgeeks.org") elif '.com' in query: query = query.replace("open ", "") query = query.strip() web(query) update_histroy(("opened" + query)) elif '.in' in query: query = query.replace("open ", "") query = query.strip() web(query) update_histroy(("opened" + query)) elif '.org' in query: query = query.replace("open ", "") query = query.strip() web(query) update_histroy(("opened" + query)) elif 'open my website' in query: web("aditya-khemka.github.io") update_histroy(("opened aditya-khemka.github.io")) elif 'search youtube for' in query: speak('Opening YouTube...') query = query.replace("search youtube for", "") query = query.strip() link = "https://www.youtube.com/results?search_query=" + query + "" web(link) update_histroy(("searched YouTube for " + query)) elif 'google for' in query: speak('Opening Google...') query = query.replace("search ", "") query = query.replace("google for", "") query = query.strip() link = "https://www.google.com/search?q=" + query + "&oq=" + query + "+&aqs=chrome.0.69i59j69i57.2093j0j1&sourceid=chrome&ie=UTF-8" web(link) update_histroy(("searched Google for " + query)) elif 'image' in query or 'images' in query: keyword = keyword.replace("images", "image") index = keyword.find('image') head = keyword[:index] keyword = keyword.replace(head, "") keyword = keyword.replace("image", "") keyword = keyword.replace("of", "") print("showing images of " + keyword + " in google") web("https://www.google.com/search?tbm=isch&sxsrf=ALeKk01IAim60Fo3Z5AQu8pK2VTCY5B8rg%3A1601865569267&source=hp&biw=1280&bih=648&ei=YYd6X8qnDsP59QPA55TIDA&q=" + keyword + "&oq=" + keyword + "&gs_lcp=CgNpbWcQAzIFCAAQsQMyBQgAELEDMgUIABCxAzIFCAAQsQMyBQgAELEDMgUIABCxAzIFCAAQsQMyBQgAELEDMgUIABCxAzIFCAAQsQM6CAgAELEDEIMBOgIIAFC_GFjBH2DmJmgAcAB4AIABwwGIAa8HkgEDMC41mAEAoAEBqgELZ3dzLXdpei1pbWc&sclient=img&ved=0ahUKEwiK3O2htpzsAhXDfH0KHcAzBckQ4dUDCAc&uact=5" ) elif 'play music' in query: speak("Playing music") music_dir = "F:\\aditya\\Python development" songs = os.listdir(music_dir) print(songs) os.startfile(os.path.join(music_dir, songs[4])) update_histroy("played music") elif 'the time' in query: strTime = datetime.datetime.now().strftime("%H:%M:%S") speak(f"Sir, the time is {strTime}") update_histroy("asked for the time") elif 'open text' in query: codePath = "C:\\Program Files\\Sublime Text\\subl.exe" os.startfile(codePath) update_histroy("opened sublime text" + query) elif 'joke' in query: speak(pyjokes.get_joke()) update_histroy("cracked a joke") elif "don't listen" in query or "stop listening" in query: speak("Sir, for how much time shall I remain silence?") a = int(takeCommand()) print(a) speak("silent for" + ((str)(a)) + "seconds") update_histroy("played music") time.sleep(a) elif "where is" in query or "locate" in query: query = query.replace("where is", "") query = query.replace("locate", "") speak("Searching for ...") speak(query) web("https://www.google.com/maps/search/" + query + "") update_histroy(("located" + query + "on maps")) elif "write a note" in query or "take a note" in query: speak("Sir, what must I write") note = takeCommand() file = open('andro.txt', 'w') speak("Sir, Should i include date and time") snfm = takeCommand() if 'yes' in snfm or 'sure' in snfm or 'yup' in snfm: strTime = datetime.datetime.now().strftime("%H:%M:%S") file.write(strTime) file.write(" :- ") file.write(note) else: file.write(note) speak("Note added") update_histroy("added a note") elif "show" in query and "note" in query or "so note" in query: speak("Showing Notes") file = open("andro.txt", "r") print(file.read()) speak(file.read(6)) time.sleep(2) update_histroy("read notes") elif 'who made you' in query: speak( 'I am a smart virtual assistant made by Aditya Khemka. Here is sirs portfolio website' ) web("aditya-khemka.github.io") elif 'stock' in query or 'share' in query: speak("Sir, please enter stock exchange and brand symbol") stockInfo() elif 'translate' in query and 'english' in query: text = input("Enter text to translate: ") print(Translate_Text(text, "en")) update_histroy(("translated " + text + "to english")) elif 'translate' in query: text = input("Enter text to translate: ") lang_code = input("Enter Language Code: ") Translate_Text(text, lang_code) update_histroy(("translated " + text + "to " + lang_code)) elif 'play' in query and 'youtube' in query: speak("Sir, please say the keywords to search for") keyword = takeCommand() YouTubePlay(keyword) update_histroy(("played YouTube video on " + keyword)) elif 'whatsapp' in query: speak("sir, please type the receiver's phone number") no = input("Receiver's 10 digit number number: ") speak("sir, please type the message to be sent") msg = input("message: ") whatsapp_message(msg, no) update_histroy(("sent whatsapp message to " + no)) elif 'help' in query or 'support' in query: print("****** Andro by Aditya Khemka ******") print("mail me at [email protected]") print("visit https://wwwkhemkaaditya.wixsite.com/andro") time.sleep(5) speak("opening forum") web("wwwkhemkaaditya.wixsite.com/andro") elif 'so history' in query or 'show history' in query: show_history() elif 'delete history' in query and 'clear history' in query: clear_history() elif 'the day' in query: x = datetime.datetime.now() day = x.strftime("%A") speak("sir, today is a" + day) update_histroy("checked today's day") elif 'the date' in query: x = datetime.datetime.now() today = "Sir, today is " + x.strftime("%d") + " " + x.strftime( "%B") + " " + x.strftime("%Y") + "." speak(today) print(today) update_histroy("checked today's date") elif 'take image' in query or 'capture' in query or 'photo' in query: print("preparing to capture image") speak("sir, please smile for an image") ec.capture(0, "andro", "img.jpg") update_histroy("took a selfie") elif ('sleep' in query or 'hibernate' in query) and ( 'pc' in query or 'computer' in query or 'system' in query): print("your PC will go to hibernate in 15 secomds ...") speak("your PC will go to hibernate in 15 secomds") update_histroy("intialized computer hybernation") os.system("shutdown /h /t 15") elif ('shutdown' in query) and ('pc' in query or 'computer' in query or 'system' in query): print( "your PC will shutdown in 30 seconds. To cancel shutdown, call 'cancelShutdown'" ) speak("sir, your PC will shutdown in 30 seconds") update_histroy("initialised computer shutdown") os.system("shutdown /s /t 30") elif ('restart' in query) and ('pc' in query or 'computer' in query or 'system' in query): print( "your PC will restart in 30 seconds. To cancel restart, call 'cancelShutdown'" ) speak("sir, your PC will restart in 30 seconds") update_histroy("initialised computer restart") os.system("shutdown /r /t 30") elif 'cancel' in query and ('restart' in query or 'shutdown' in query): cont = "shutdown/a" print("shutdown cancelled...") speak("shutdown cancelled") update_histroy("cancelled computer shutdown") os.system(cont) elif 'timer' in query or 'countdown' in query: #https://www.geeksforgeeks.org/how-to-create-a-countdown-timer-using-python/ speak("sir, please enter the time in seconds") t = input("Enter the time in seconds: ") update_histroy("set a timer for" + t + "seconds") while t: mins, secs = divmod(t, 60) timer = '{:02d}:{:02d}'.format(mins, secs) print(timer, end="\r") time.sleep(1) t -= 1 print("time over") winsound.Beep(1000, 2000) time.sleep(0.25) speak("time over") elif 'hello' in query: speak("Hi! I am andro. how may i help you ?") elif 'how are you' in query: speak("I am fine, Thank you") speak("How are you, Sir") elif 'I am fine' in query or "good" in query: speak("It's good to know that your fine") elif "will you be my gf" in query or "will you be my bf" in query: speak("I'm not sure about, may be you should give me some time") elif "how are you" in query: speak("I'm fine, glad you me that") elif "i love you" in query: speak("It's hard to understand") elif 'exit' in query: speak("Thanks for giving me your time") update_histroy("closed andro") exit() elif 'none' not in query: speak("Sorry Sir, I could not fetch any results for the query") print("Error")
def andro(): speak("initializing andro") splash_screen() wishMe() alram() os.system('CLS') while True: print("========================================================================================") query = takeCommand().lower() # accepts input # Logic for executing tasks based on query if 'wikipedia' in query: # search wikipedia speak('Searching Wikipedia...') query = query.replace("wikipedia", "") results = wikipedia.summary(query, sentences=2) speak("According to Wikipedia") print(results) speak(results) update_histroy(("wikipedia search for" + query)) elif 'who made you' in query: speak('I am a smart virtual assistant made by Aditya Khemka. Here is sirs portfolio website') web("aditya-khemka.github.io") #opening websites and apps elif 'open youtube' in query: web("youtube.com") update_histroy("opened youtube.com") elif 'open google' in query: web("google.com") update_histroy("opened google.com") elif 'open stack overflow' in query: web("stackoverflow.com") update_histroy("opened stackoverflow.com") elif 'open github' in query: web("github.com") update_histroy("opened github.com") elif 'open unacademy' in query: web("unacademy.com") update_histroy("opened unacademy.com") elif 'geeks' in query and 'for' in query: web("geeksforgeeks.org") update_histroy("opened geeksforgeeks.org") elif '.com' in query: query = query.replace("open ", "") query = query.strip() web(query) update_histroy(("opened" + query)) elif '.in' in query: query = query.replace("open ", "") query = query.strip() web(query) update_histroy(("opened" + query)) elif '.org' in query: query = query.replace("open ", "") query = query.strip() web(query) update_histroy(("opened" + query)) elif 'open my website' in query: web("aditya-khemka.github.io") update_histroy(("opened aditya-khemka.github.io")) elif 'open text' in query: codePath = "C:\\Program Files\\Sublime Text\\subl.exe" os.startfile(codePath) update_histroy("opened sublime text" + query) #searching websites elif 'search youtube for' in query: speak('Opening YouTube...') query = query.replace("search youtube for", "") query = query.strip() link = "https://www.youtube.com/results?search_query=" + query + "" web(link) update_histroy(("searched YouTube for " + query)) elif 'google for' in query: speak('Opening Google...') query = query.replace("search ", "") query = query.replace("google for", "") query = query.strip() link = "https://www.google.com/search?q=" + query + "&oq=" + query + "+&aqs=chrome.0.69i59j69i57.2093j0j1&sourceid=chrome&ie=UTF-8" web(link) update_histroy(("searched Google for " + query)) elif "where is" in query or "locate" in query: query = query.replace("where is", "") query = query.replace("locate", "") speak("Searching for ...") speak(query) web("https://www.google.com/maps/search/" + query + "") update_histroy(("located"+query+"on maps")) elif 'image' in query or 'images' in query: keyword=keyword.replace("images","image") index = keyword.find('image') head=keyword[:index] keyword=keyword.replace(head,"") keyword=keyword.replace("image","") keyword=keyword.replace("of","") print("showing images of "+keyword+" in google") web("https://www.google.com/search?tbm=isch&sxsrf=ALeKk01IAim60Fo3Z5AQu8pK2VTCY5B8rg%3A1601865569267&source=hp&biw=1280&bih=648&ei=YYd6X8qnDsP59QPA55TIDA&q="+keyword+"&oq="+keyword+"&gs_lcp=CgNpbWcQAzIFCAAQsQMyBQgAELEDMgUIABCxAzIFCAAQsQMyBQgAELEDMgUIABCxAzIFCAAQsQMyBQgAELEDMgUIABCxAzIFCAAQsQM6CAgAELEDEIMBOgIIAFC_GFjBH2DmJmgAcAB4AIABwwGIAa8HkgEDMC41mAEAoAEBqgELZ3dzLXdpei1pbWc&sclient=img&ved=0ahUKEwiK3O2htpzsAhXDfH0KHcAzBckQ4dUDCAc&uact=5") update_histroy(("searched for images of "+keyword+"on google")) elif 'play' in query and 'youtube' in query: speak("Sir, please say the keywords to search for") keyword = takeCommand() YouTubePlay(keyword) update_histroy(("played YouTube video on "+keyword)) #cracks jokes elif 'joke' in query: speak(pyjokes.get_joke()) update_histroy("cracked a joke") #playing music elif 'play music' in query: speak("Playing music") music_dir = "F:\\aditya\\Python development" songs = os.listdir(music_dir) print(songs) os.startfile(os.path.join(music_dir, songs[4])) update_histroy("played music") #checking time and day elif 'the time' in query: strTime = datetime.datetime.now().strftime("%H:%M:%S") speak(f"Sir, the time is {strTime}") update_histroy("asked for the time") elif 'timer' in query or 'countdown' in query: #https://www.geeksforgeeks.org/how-to-create-a-countdown-timer-using-python/ speak("sir, please enter the time in seconds") t = input("Enter the time in seconds: ") update_histroy("set a timer for"+t+"seconds") while t: mins, secs = divmod(t, 60) timer = '{:02d}:{:02d}'.format(mins, secs) print(timer, end="\r") time.sleep(1) t -= 1 print("time over") winsound.Beep(1000, 2000) time.sleep(0.25) speak("time over") elif 'the day' in query: x = datetime.datetime.now() day=x.strftime("%A") speak("sir, today is a"+day) update_histroy("checked today's day") elif 'the date' in query: x = datetime.datetime.now() today = "Sir, today is "+ x.strftime("%d") + " " + x.strftime("%B") + " " + x.strftime("%Y") + "." speak(today) print(today) update_histroy("checked today's date") #mute functions elif "don't listen" in query or "stop listening" in query: speak("Sir, for how much time shall I remain silence?") a = int(takeCommand()) print(a) speak("silent for"+((str)(a))+"seconds") update_histroy("played music") time.sleep(a) # actual usage of virtual assistant elif "algebra" in query or "calculator" in query: app_id = alpha client = wolframalpha.Client(app_id) question=input("Question please: ") res = client.query(question) answer = next(res.results).text print("answer: "+answer) speak("The answer is " ) speak(answer) update_histroy("calculated "+question) elif "what is" in query or "who is" in query or "why is" in query or "when is" in query: client = wolframalpha.Client(alpha) #connecting to wolfram alpha try: res = client.query(query) except Exception as e: speak("Sorry Sir, the server encountered a problem") continue #gathering information try: print (next(res.results).text) speak (next(res.results).text) except Exception as e: print ("No results") speak ("Sorry sir, I could not fetch any results. Opening google for the query") query = query.replace("what", "") query = query.replace("who", "") query = query.replace("when", "") query = query.replace("why", "") query = query.replace("is", "") query = query.replace("are", "") query=query.strip() link="https://www.google.com/search?q="+query+"&oq="+query+"+&aqs=chrome.0.69i59j69i57.2093j0j1&sourceid=chrome&ie=UTF-8" web(link) #phir bhi koi galti hua toh except Exception as e: speak("Sorry Sir, the server encountered a problem") continue update_histroy("learnt about '"+query+"'") #about the weather elif "weather" in query or "temperature" in query: api_key = weather base_url = "http://api.openweathermap.org/data/2.5/weather?" speak("Sir, please tell the city name") city_name = takeCommand() print("City name : ") print(city_name) complete_url = base_url + "appid=" + api_key + "&q=" + city_name response = requests.get(complete_url) x = response.json() if x["cod"] != "404": y = x["main"] current_temperature = y["temp"] current_pressure = y["pressure"] current_humidiy = y["humidity"] z = x["weather"] weather_description = z[0]["description"] print(" Temperature (in kelvin unit) = " +str(current_temperature)+"\n atmospheric pressure (in hPa unit) ="+str(current_pressure) +"\n humidity (in percentage) = " +str(current_humidiy) +"\n description = " +str(weather_description)) speak(" Temperature (in kelvin unit) = " +str(current_temperature)+"\n atmospheric pressure (in hPa unit) ="+str(current_pressure) +"\n humidity (in percentage) = " +str(current_humidiy) +"\n description " +str(weather_description)) else: speak(" City Not Found ") update_histroy("checked weather in "+city_name) #taking notes elif "write a note" in query or "take a note" in query: speak("Sir, what must I write") note = takeCommand() file = open('andro.txt', 'w') speak("Sir, Should i include date and time") snfm = takeCommand() if 'yes' in snfm or 'sure' in snfm or 'yup' in snfm: strTime = datetime.datetime.now().strftime("%H:%M:%S") file.write(strTime) file.write(" :- ") file.write(note) else: file.write(note) speak("Note added") update_histroy("added a note") elif "show" in query and "note" in query or "so note" in query: speak("Showing Notes") file = open("andro.txt", "r") print(file.read()) speak(file.read(6)) time.sleep(2) update_histroy("read notes") #IFTTT usage elif 'alert' in query and 'message' in query: speak("Sir, a message has been sent to you from IFTTT") requests.get("https://maker.ifttt.com/trigger/msg/with/key/"+ifttt) update_histroy("sent alert message") elif 'ring' in query or 'call' in query: speak("Ringing device") requests.get("https://maker.ifttt.com/trigger/call/with/key/"+ifttt) update_histroy("rang device") elif 'notification' in query or 'notify' in query: speak("Sir, a notification has been sent to you from IFTTT") requests.get("https://maker.ifttt.com/trigger/notify/with/key/"+ifttt) update_histroy("sent notification") #stock price elif 'stock' in query or 'share' in query: speak("Sir, please enter stock exchange and brand symbol") stockInfo() #translating functions elif 'translate' in query and 'english' in query: text = input("Enter text to translate: ") print (Translate_Text(text, "en")) update_histroy(("translated "+text+"to english")) elif 'translate' in query: text = input("Enter text to translate: ") lang_code = input("Enter Language Code: ") Translate_Text(text, lang_code) update_histroy(("translated "+text+"to "+lang_code)) #sending messages elif 'whatsapp' in query: speak("sir, please type the receiver's phone number") no = input("Receiver's 10 digit number number: ") speak("sir, please type the message to be sent") msg = input("message: ") whatsapp_message(msg, no) update_histroy(("sent whatsapp message to "+no)) elif 'email to aditya' in query: try: speak("Sir, please type the content") content = input("Content of the email please: ") to = "*****@*****.**" sendEmail(to, content) speak("Email has been sent!") except Exception as e: print(e) speak("Sorry Sir. I could not send this email") update_histroy("sent email to aditya") elif 'send an email' in query or 'send a mail' in query: try: speak("Sir, please type the content") content = input("Content of the email please: ") speak("Sir, please type the receiver's address ") print("Sir, please type the receiver's address: ") to = input() sendEmail(to, content) speak("Email has been sent !") except Exception as e: print(e) speak("Sorry Sir. I could not send this email") update_histroy("sent email to "+to) elif 'message' in query and 'text' in query: speak("Sir, please enter the message to send") message = input ("Enter message: ") speak("Sir, please enter phone numbers to send sms to") numbers = input ("Enter numbers seperated by commas: ") send_message(message,numbers) speak("Message sent") update_histroy("sent messages to "+numbers) #reading headlines elif 'headlines' in query: News() update_histroy("read headlines") #history ... elif 'so history' in query or 'show history' in query : show_history() elif 'delete history' in query and 'clear history' in query : clear_history() #selfie elif 'take image' in query or 'capture' in query or 'photo' in query: print("preparing to capture image") speak("sir, please smile for an image") ec.capture(0,"andro","img.jpg") update_histroy("took a selfie") #PC related functions elif ('sleep' in query or 'hibernate' in query) and ('pc' in query or 'computer' in query or 'system' in query) : print("your PC will go to hibernate in 15 secomds ...") speak("your PC will go to hibernate in 15 secomds") update_histroy("intialized computer hybernation") os.system("shutdown /h /t 15") elif ('shutdown' in query) and ('pc' in query or 'computer' in query or 'system' in query) : print("your PC will shutdown in 30 seconds. To cancel shutdown, call 'cancelShutdown'") speak("sir, your PC will shutdown in 30 seconds") update_histroy("initialised computer shutdown") os.system("shutdown /s /t 30") elif ('restart' in query) and ('pc' in query or 'computer' in query or 'system' in query) : print("your PC will restart in 30 seconds. To cancel restart, call 'cancelShutdown'") speak("sir, your PC will restart in 30 seconds") update_histroy("initialised computer restart") os.system("shutdown /r /t 30") elif 'cancel' in query and ('restart' in query or 'shutdown' in query) : cont = "shutdown/a" print("shutdown cancelled...") speak("shutdown cancelled") update_histroy("cancelled computer shutdown") os.system(cont) #location elif 'my location' in query or 'where am I' in query : send_url = "http://api.ipstack.com/check?access_key="+iplocation geo_req = requests.get(send_url) geo_json = json.loads(geo_req.text) city = geo_json['city'] print("your IP location: "+city) speak("sir, your IP location is: "+city) update_histroy("checked your location") #communications ... elif 'help' in query or 'support' in query: print("****** Andro by Aditya Khemka ******") print("mail me at [email protected]") print("visit https://wwwkhemkaaditya.wixsite.com/andro") time.sleep(5) speak("opening forum") web("wwwkhemkaaditya.wixsite.com/andro") elif 'hello' in query: speak("Hi! I am andro. how may i help you ?") elif 'how are you' in query: speak("I am fine, Thank you") speak("How are you, Sir") elif 'I am fine' in query or "good" in query: speak("It's good to know that your fine") elif "will you be my gf" in query or "will you be my bf" in query: speak("I'm not sure about, may be you should give me some time") elif "how are you" in query: speak("I'm fine, glad you me that") elif "i love you" in query: speak("It's hard to understand") elif 'exit' in query: speak("Thanks for giving me your time") update_histroy("closed andro") exit() elif 'none' not in query: speak("Sorry Sir, I could not fetch any results for the query") print("Error")
def digital_assistant(data): try: if data == "jarvis": respond("yes sir! I am at your service") return elif "how are you" in data: respond("I am well") return elif contain(data,["define yourself","what can you do","who are you"]): respond("I am viswanadh's personal assistant, I am programmed to do minor tasks like system monitoring, profiling," "predict time, take a photo, predict weather," " opening applications like youtube, google chrome ,gmail etcetre, show the top headline news and you can ask me computational or geographical questions too!") return elif contain(data,["who made you","who created you"]): respond("I was built by viswa") return elif "shutdown" in data: respond("Are you sure! you want to shutdown your computer") data = listen() if data == "yes": respond("system is going to shutdown...") os.system("taskkill /f /im Rainmeter.exe") os.system("shutdown /s /t 1") return elif "restart" in data: respond("want to restart your computer") data=listen() if data=="yes": os.system("shutdown /r /t 1") return elif "music" in data: respond("Here you go with music") music_dir = "C:\\Users\\VISWANADH\\Music" song = random.choice(os.listdir(music_dir)) os.startfile(os.path.join(music_dir,song)) time.sleep(5) return elif "movie" in data: os.system("D:\\movies\\Ala_Vaikunthapurramloo.mkv") time.sleep(5) return elif "notepad" in data: os.system("notepad") return elif contain(data,['select all','cut','copy','paste','history','download','undo','redo','save','enter','search','find']): Ctrl_Keys(data) return elif "open" in data: if "tab" in data: Tab_Opt(data) time.sleep(10) respond("what do you wanna search sir!") data = listen() if "search" in data: keys.Paste() else: pyautogui.typewrite(data) keys.Enter() elif "window" in data: Win_Opt(data) elif "chrome" in data: time.sleep(3) webbrowser.open("http://www.google.com/") time.sleep(10) respond("what do you wanna search sir!") data = listen() if "search" in data: keys.Paste() else: pyautogui.typewrite(data) keys.Enter() else: data = data.split(" ") query = data[1] for j in search(query, tld='com', lang='en', num=1, start=0, stop=1, pause=2.0): url=j webbrowser.get('chrome').open_new(url) respond(data[1] + " is open now") time.sleep(7) return elif "news" in data: query = "news" url="https://timesofindia.indiatimes.com/home/headlines" webbrowser.get('chrome').open_new(url) respond("Here are some headlines from the Times of India,Happy reading") time.sleep(5) return elif "weather" in data: data=data.split(" ") api_key = "###############################" base_url = "https://api.openweathermap.org/data/2.5/weather?" if "in" not in data: city_name = "kurupam" else: city_name = data[-1] complete_url = base_url + "appid=" + api_key + "&q=" + city_name response = requests.get(complete_url) x = response.json() if x["cod"] != "404": y = x["main"] current_temperature = y["temp"] current_humidiy = y["humidity"] z = x["weather"] weather_description = z[0]["description"] respond(" Temperature in kelvin unit at " + city_name + " is " + str(current_temperature) + "\n humidity in percentage is " + str(current_humidiy) + "\n description " + str(weather_description)) return else: respond(city_name + " weather details not found") return elif "something" in data: respond("Searching...") data=data.split(" ") data = data[3:] Req_data = "" for word in data: Req_data = Req_data + " " + word data = "According to wikipedia " + wikipedia.summary(Req_data, sentences=4) respond(data) return elif contain(data,["take a photo","capture the photo"]): ec.capture(0,False,"img.jpg") respond("photo captured successfully") return elif contain(data,["video","record the video"]): ec.auto_vidcapture(0,False,"video.mkv",10) respond("video recorded successfully") return elif "access" in data: access() return elif "where is" in data: data = data.split(" ") name = data[-1] url = "https://www.google.com/maps/place/"+name webbrowser.get('chrome').open_new(url) time.sleep(5) return elif "write a note" in data: respond("What should i write, sir!") data = listen() file = open('note.txt', 'a') file.write("\n"+ctime()+"\n") file.write(data) respond("noted successfully") return elif "execute" in data: execute_commands() return elif contain(data,["upcoming events","scheduled events","events"]): calendar_events() return elif contain(data,["game","play"]): try: tic_tac_toe() return except: return elif "create event" in data: create_event() return elif contain(data,["speed test","internet speed"]): try: respond("sure! wait a second to measure") st = speedtest.Speedtest() server_names = [] st.get_servers(server_names) ping = st.results.ping downlink_Mbps = round(st.download() / 1000000, 2) uplink_Mbps = round(st.upload() / 1000000, 2) respond('ping {} ms'.format(ping)) respond("The uplink is {} Mbps".format(uplink_Mbps)) respond("The downlink is {}Mbps".format(downlink_Mbps)) return except: respond ("I couldn't run a speedtest") return elif contain(data,["internet connection","connection"]): if internet_availability(): respond("Internet Connection is okay!") return elif "wait" in data: respond("okay sir") time.sleep(10) return elif "screenshot" in data: Screenshot = pyautogui.screenshot() dir = "C:\\Users\VISWANADH\Pictures\Screenshots" length = len(os.listdir(dir)) Screenshot_name = "Screenshot({}).png".format(length) path = os.path.join(dir,Screenshot_name) Screenshot.save(path) respond("Screenshot saved Successfully!") return elif "tab" in data: Tab_Opt(data) return elif "window" in data: Win_Opt(data) return elif contain(data,['battery', 'cpu', 'memory', 'brightness']): System_specs(data) return elif "time" in data: respond(ctime()) return else: respond("I can search the web for you,Do you want to continue?") opinion=listen() if opinion=="yes": url="https://www.google.com/search?q =" + '+'.join(data.split()) webbrowser.get('chrome').open_new(url) time.sleep(5) return else: return except: respond("I don't understand, I can search the web for you,Do you want to continue?") opinion=listen() if opinion=="yes": url="https://www.google.com/search?q =" + '+'.join(data.split()) webbrowser.get('chrome').open_new(url) time.sleep(5) return else: return
"for how much time you want to stop {assiname} from listening commands" ) a = int(takeCommand()) time.sleep(a) print(a) elif "where is" in query: query = query.replace("where is", "") location = query speak("User asked to Locate") speak(location) webbrowser.open("https://www.google.com / maps / place/" + location + "") elif "camera" in query or "take a photo" in query: ec.capture(0, "Cool Camera ", "img.jpg") elif "write a note" in query: speak("What should i write") note = takeCommand() file = open('notes.txt', 'w') speak("Should i include date and time") snfm = takeCommand() if 'yes' in snfm or 'sure' in snfm: strTime = str(datetime.datetime.now().strftime("% H:% M:% S")) file.write(strTime) file.write(" :- ") file.write(note) else: file.write(note) file.close()
def pic_func(): global imglabel imglabel = "Images/" + str(datetime.now()) + '.jpg' (ec.capture(1, False, imglabel))
"for how much time you want to stop AISHA from listening commands" ) a = int(takeCommand()) time.sleep(a) print(a) elif "where is" in query: query = query.replace("where is", "") location = query speak("User asked to Locate") speak(location) webbrowser.open("https://www.google.nl / maps / place/" + location + "") elif "camera" in query or "take a photo" in query: ec.capture(0, "AISHA Camera ", "img.jpg") elif "restart" in query: subprocess.call(["shutdown", "/r"]) elif "hibernate" in query or "sleep" in query: speak("Hibernating") subprocess.call("shutdown / h") elif "log off" in query or "sign out" in query: speak("Make sure all the application are closed before sign-out") time.sleep(5) subprocess.call(["shutdown", "/l"]) elif "write a note" in query: speak("What should i write, sir")
message.attach(msg) message['To'] = "*****@*****.**" message['From'] = username message['Subject'] = "Intrusion Detected" text = message.as_string() server.sendmail(username, "*****@*****.**", text) return text """ server = smtplib.SMTP('smtp.gmail.com', 587) server.ehlo() server.starttls() server.login("*****@*****.**", '0101guymargalit') username = '******'""" ec.capture(0, "Face ID", "face.jpg") if not is_guy("face.jpg"): email_intruder("face.jpg") while 1: if keyboard.is_pressed("ctrl+space"): ec.capture(0, "Face ID", "face.jpg") if is_guy("face.jpg"): break email_intruder("face.jpg") latest = "" speaker = win32com.client.Dispatch("SAPI.SpVoice") greet_me() recognizer = sr.Recognizer() microphone = sr.Microphone() page = subprocess.getoutput( 'curl "https://miapi.pandorabots.com/talk" -H "Sec-Fetch-Mode: cors" -H '
def digital_assistant(data): try: if "how are you" in data: respond("I am well") return elif "time" in data: respond(ctime()) return elif "who are you" in data or "what can you do" in data or "define yourself" in data: engine.say( "I am viswanadh's personal assistant, I am programmed to do minor tasks like system monitoring, profiling," "predict time, take a photo, predict weather," " opening applications like youtube, google chrome ,gmail etcetre, show the top headline news and you can ask me computational or geographical questions too!" ) return elif "who made you" in data or "who created you" in data: respond("I was built by viswa") return elif "joke" in data: respond(pyjokes.get_joke) return elif "shutdown" in data: respond("Are you sure! you want to shutdown your computer") data = listen() if data == "yes": os.system("shutdown /s /t 1") return elif "restart" in data: respond("want to restart your computer") data = listen() if data == "yes": os.system("shutdown /r /t 1") return elif "battery" in data or "cpu" in data: battery = psutil.sensors_battery() respond("Battery is at " + str(battery.percent) + " percent") return elif "cpu" in data: respond("CPU is at " + str(psutil.cpu_percent())) return elif "music" in data: os.system("D:\\music\\RaceGurram\\Down_Down.mp3") time.sleep(5) return elif "movie" in data: os.system("D:\\movies\\Ala_Vaikunthapurramloo.mkv") time.sleep(5) return elif "open" in data: data = data.split(" ") query = data[1] for j in search(query, tld='com', lang='en', num=1, start=0, stop=1, pause=2.0): url = j webbrowser.get('chrome').open_new(url) respond(data[1] + "is open now") time.sleep(7) return elif "news" in data: query = "news" url = "https://timesofindia.indiatimes.com/home/headlines" webbrowser.get('chrome').open_new(url) respond( "Here are some headlines from the Times of India,Happy reading" ) time.sleep(5) return elif "weather" in data: data = data.split(" ") api_key = "c046999b657d072a1dd2d413fd4dd156" base_url = "https://api.openweathermap.org/data/2.5/weather?" city_name = "kurupam" complete_url = base_url + "appid=" + api_key + "&q=" + city_name response = requests.get(complete_url) x = response.json() if x["cod"] != "404": y = x["main"] current_temperature = y["temp"] current_humidiy = y["humidity"] z = x["weather"] weather_description = z[0]["description"] respond(" Temperature in kelvin unit is " + str(current_temperature) + "\n humidity in percentage is " + str(current_humidiy) + "\n description " + str(weather_description)) return else: respond(city_name + " weather details not found") return elif "something" in data: respond("Searching...") data = data[22:] respond("According to wikipedia") respond(wikipedia.summary(data, sentences=4)) return elif "capture the photo" in data or "take a photo" in data: ec.capture(0, False, "img.jpg") respond("photo captured successfully") return elif "video" in data or "capture the video" in data: ec.auto_vidcapture(0, False, "video.mkv", 10) respond("video recorded successfully") return else: respond("I can search the web for you,Do you want to continue?") opinion = listen() if opinion == "yes": url = "https://www.google.com/search?q =" + '+'.join( data.split()) webbrowser.get('chrome').open_new(url) time.sleep(5) return else: return except: respond( "I don't understand, I can search the web for you,Do you want to continue?" ) opinion = listen() if opinion == "yes": url = "https://www.google.com/search?q =" + '+'.join(data.split()) webbrowser.get('chrome').open_new(url) time.sleep(5) return else: return
elif 'achtergrond' in text: ctypes.windll.user32.SystemParametersInfoW( 20, 0, "C:\\Users\\youri\\Pictures\\epicfoto.jpg", 0) speak("ik heb je achtergrond veranderd") elif "waar is" in text: #werkt nu wel query = text.replace("waar is", "") #verplaatst "waar is" in bestand speak(f"Gebruiker vraagt naar locatie {query}" ) #overgebleven plaatsmaa, om zom webbrowser.open("https://www.google.nl/maps/place/" + query + "") #zoekt op base url icm query elif "camera" in text or "foto" in text: (ec.capture(0, False, "img.jpg")) #maakt foto onder naam img.jpg speak("Foto is gemaakt") elif "maak een notitie" in text: speak("wat moet ik noteren?") note = get_audio() #spraak in variabele note file = open('jarvis.txt', 'w') #creeerd een file jarvis.txt speak("Moet ik de datum en tijd bijvoegen") snfm = get_audio() #vraagt naar datum en tijd if 'ja' in snfm or 'okay' in snfm or 'goed' in snfm: #akkoord in spraak strTime = datetime.now().strftime("%d-%m") #haalt datum op file.write(strTime) #zet datum in notitie file.write(" :- ") file.write(note) #zet notitie in notitie else: file.write(note)
elif "who are you" in query: speak("I am your assistant created by Jatin Kumawat") elif 'reason for you' in query: speak("I was created as a fun by jatin ") elif "where is" in query: query = query.replace("where is", "") location = query speak("User asked to Locate") speak(location) wb.open("https://www.google.co.in/maps/place/" + location + "") elif "camera" in query or "take a photo" in query: ec.capture(0, "alita Camera ", "img.jpg") elif "write a note" in query: speak("What should i write, sir") note = takeCommand() file = open('nete.txt', 'w') speak("Sir, Should i include date and time") snfm = takeCommand() if 'yes' in snfm or 'sure' in snfm: strTime = datetime.datetime.now().strftime("% H:% M:% S") file.write(strTime) file.write(" :- ") file.write(note) else: file.write(note)
from __future__ import absolute_import, division, print_function, unicode_literals # TensorFlow and tf.keras import tensorflow as tf from tensorflow import keras AUTOTUNE = tf.data.experimental.AUTOTUNE import IPython.display as display from PIL import Image import numpy as np import matplotlib.pyplot as plt import os from tensorflow.keras.preprocessing.image import ImageDataGenerator from tensorflow.keras.preprocessing.image import load_img from tensorflow.keras.preprocessing.image import img_to_array #print(tf.__version__) from ecapture import ecapture as ec ec.capture() model = keras.models.load_model('/home/falcon/garbageai/model/keras_model.h5') #Retreive Images test_image = '/home/falcon/garbageai/test_cb_plastic/tests/pic2.png' im = load_img(test_image, target_size=(150, 150)) # -> PIL image im_array = img_to_array(im) im_array = np.expand_dims(im_array, axis=0) im_array[0] = im_array[0] / 255 prediction = model.predict(im_array)
elif "who made you" in statement or "who created you" in statement or "who discovered you" in statement: speak("I was built by Qasim uddin") print("I was built by Qasim") elif "open stackoverflow" in statement: webbrowser.open_new_tab("https://stackoverflow.com/login") speak("Here is stackoverflow") elif 'news' in statement: news = webbrowser.open_new_tab("https://timesofindia.indiatimes.com/home/headlines") speak('Here are some headlines from the Times of India,Happy reading') time.sleep(6) elif "camera" in statement or "take a photo" in statement: ec.capture(0, "robo camera", "img.jpg") elif 'search' in statement: statement = statement.replace("search", "") webbrowser.open_new_tab(statement) time.sleep(5) elif 'send email' in statement: try: speak("What should I say?") content = statement to = "*****@*****.**" sendEmail(to, content) speak("Email has been sent!") except Exception as e: print(e)
from ecapture import ecapture as ec ec.capture(0,False,"img.jpg")
def take_photo(): #webcam üzerinden fotoğraf çeken ve kaydeden method rand = random.randint(1,1000) speak("Gülümse çekiyorum") (ec.capture(0, "Ciri Camera", str(rand) +"img.jpg"))
speak("Recycle Bin recycled!") elif "don't listen" in query or "stop listening" in query: speak("for how much time you want to stop Zoe from listening commands") a=int(takeCommand()) time.sleep(a) elif "where is" in query: query=query.replace("Where is"," ") location=query speak("User asked to Locate") speak(location) webbrowser.open("https://www.google.nl//map/place/"+location+" ") elif "camera" in query or "take a photo" in query or "take a pic": ec.capture(0,"ZOe Camera","imag.jpg") elif "restart" in query: subprocess.call("shutdown","/r") elif "hibernate" in query or "sleep" in query: speak("Hibernating") subprocess.call("shutdown","/h") elif "chrome" in query: speak("Google chrome") os.startfile('C:\Program Files (x86)\Google\Chrome\Application\chrome.exe') elif "firefox" in query or "mozilla" in query: speak("Opening Mozilla Firefox") os.startfile('C:\Program Files\Mozilla Firefox\\firefox.exe')