├── LICENSE ├── README.md └── jarvis.py /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Arbaz Khan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JARVIS-Udemy-Code 2 | Source Code Of:- https://www.udemy.com/course/learn-to-create-ai-assistant-jarvis-with-python/learn/ 3 | 4 | 5 | 6 | [![forthebadge made-with-python](http://ForTheBadge.com/images/badges/made-with-python.svg)](https://www.python.org/) [![Python 3.6](https://img.shields.io/badge/python-3.6-blue.svg)](https://www.python.org/downloads/release/python-360/) [![PyPI license](https://img.shields.io/pypi/l/ansicolortags.svg)](https://pypi.python.org/pypi/ansicolortags/) 7 | 8 | [![GitHub forks](https://img.shields.io/github/forks/arbazkhan4712/JARVIS-Udemy-Code?style=social)](https://GitHub.com/Naereen/StrapDown.js/network/) [![GitHub star](https://img.shields.io/github/stars/arbazkhan4712/JARVIS-Udemy-Code?style=social)](https://GitHub.com/Naereen/StrapDown.js/network/) 9 | 10 | **DEMO VIDEO** 11 | 12 | [![IMAGE ALT TEXT HERE](https://img.youtube.com/vi/MN0X32itxFs/0.jpg)](https://www.youtube.com/watch?v=MN0X32itxFs) 13 | 14 | 15 | *pyttsx3* 16 | ```python 17 | 18 | pip install pyttsx3 19 | ``` 20 | 21 | *pywin32* 22 | ```python 23 | 24 | pip install pywin32 25 | ``` 26 | *pyaudio* 27 | ```python 28 | pip install pyaudio 29 | ``` 30 | *speech recongnition* 31 | ```python 32 | pip install SpeechRecognition 33 | ``` 34 | *wikipedia* 35 | ```python 36 | pip install wikipedia 37 | ``` 38 | 39 | ## License & Copyright 40 | © [Arbaz Khan](https://arbazkhan4712.github.io/Contact.html) 41 | 42 | Licensed under the [MIT License](LICENSE) 43 | 44 | -------------------------------------------------------------------------------- /jarvis.py: -------------------------------------------------------------------------------- 1 | import pyttsx3 # pip install pyttsx3 2 | import datetime 3 | import speech_recognition as sr # pip install SpeechRecognition 4 | import wikipedia # pip install wikipedia 5 | import smtplib 6 | import webbrowser as wb 7 | import os 8 | import pyautogui # pip install pyautogui 9 | import psutil # pip install psutil 10 | import pyjokes 11 | 12 | engine = pyttsx3.init() 13 | 14 | 15 | def speak(audio): 16 | engine.say(audio) 17 | engine.runAndWait() 18 | 19 | def time(): 20 | Time = datetime.datetime.now().strftime("%I:%M:%S") 21 | speak("the current time is") 22 | speak(Time) 23 | 24 | def date(): 25 | year = int(datetime.datetime.now().year) 26 | month = int(datetime.datetime.now().month) 27 | date = int(datetime.datetime.now().day) 28 | speak("the current date is") 29 | speak(date) 30 | speak(month) 31 | speak(year) 32 | 33 | def wishme(): 34 | speak("Welcome back sir!") 35 | time() 36 | date() 37 | hour = datetime.datetime.now().hour 38 | if hour >= 6 and hour<12: 39 | speak("Good morning sir!") 40 | elif hour >=12 and hour<18: 41 | speak("Good afternoon sir") 42 | elif hour >= 18 and hour<24: 43 | speak("Good Evening sir") 44 | else: 45 | speak("Good night sir") 46 | 47 | speak("Jarvis at your service. Please tell me how can i help you?") 48 | 49 | def takeCommand(): 50 | r = sr.Recognizer() 51 | with sr.Microphone() as source: 52 | print("Listening...") 53 | r.pause_threshold = 1 54 | audio = r.listen(source) 55 | 56 | try: 57 | print("Recongnizning...") 58 | query = r.recognize_google(audio, language='en-in') 59 | print(query) 60 | 61 | except Exception as e: 62 | print(e) 63 | speak("Say that again please...") 64 | return "None" 65 | return query 66 | 67 | def sendEmail(to, content): 68 | server = smtplib.SMTP('smtp.gmail.com', 587) 69 | server.ehlo() 70 | server.starttls() 71 | server.login('abzc@gamil.com', '123') 72 | server.sendmail('abzc@gmail.com', to, content) 73 | server.close() 74 | 75 | def screenshot(): 76 | img = pyautogui.screenshot() 77 | img.save("C:\\Users\\arbaz\\Desktop\\Open-cv\\jarvis\\ss.png") 78 | 79 | def cpu(): 80 | usage = str(psutil.cpu_percent()) 81 | speak('CPU is at'+ usage) 82 | battery = psutil.sensors_battery() 83 | speak("Battery is at") 84 | speak(battery.percent ) 85 | 86 | def jokes(): 87 | speak(pyjokes.get_joke()) 88 | 89 | if __name__ == "__main__": 90 | wishme() 91 | while True: 92 | query = takeCommand().lower() 93 | if 'time' in query: 94 | time() 95 | elif 'date' in query: 96 | date() 97 | elif 'wikipedia' in query: 98 | speak("Searching...") 99 | query = query.replace("wikipedia","") 100 | result = wikipedia.summary(query, sentences=2) 101 | print(result) 102 | speak(result) 103 | elif 'send email' in query: 104 | try: 105 | speak("What should I say?") 106 | content = takeCommand() 107 | to = 'xyz@gmail.com' 108 | sendEmail(to,content) 109 | speak("Email has been sent!") 110 | except Exception as e: 111 | print(e) 112 | speak("Uable to send the email") 113 | 114 | elif 'search in chrome' in query: 115 | speak("What should i search ?") 116 | chromepath = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s' 117 | search = takeCommand().lower() 118 | wb.get(chromepath).open_new_tab(search+'.com') 119 | 120 | elif 'logout' in query: 121 | os.system("shutdown -l") 122 | 123 | elif 'shutdown' in query: 124 | os.system("shutdown /s /t 1") 125 | 126 | elif 'restart' in query: 127 | os.system("shutdown /r /t 1") 128 | 129 | elif 'play songs' in query: 130 | songs_dir = 'D:\\Music' 131 | songs = os.listdir(songs_dir) 132 | os.startfile(os.path.join(songs_dir, songs[0])) 133 | 134 | elif 'remember that' in query: 135 | speak("What should I remember?") 136 | data = takeCommand() 137 | speak("you said me to remember that"+data) 138 | remember = open('data.txt','w') 139 | remember.write(data) 140 | remember.close() 141 | 142 | elif 'do you know anything' in query: 143 | remember =open('data.txt', 'r') 144 | speak("you said me to remember that" +remember.read()) 145 | 146 | elif 'screenshot' in query: 147 | screenshot() 148 | speak("Done!") 149 | 150 | elif 'cpu'in query: 151 | cpu() 152 | 153 | elif 'joke' in query: 154 | jokes() 155 | 156 | elif 'offline' in query: 157 | quit() 158 | --------------------------------------------------------------------------------