├── README.md └── main.py /README.md: -------------------------------------------------------------------------------- 1 | # The_Jarvis 2 | bot 3 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import pyttsx3 2 | import speech_recognition as sr 3 | import datetime 4 | import wikipedia 5 | import webbrowser 6 | import os 7 | import smtplib 8 | 9 | print("Hi! I'm Jarvis") 10 | 11 | MASTER = "Ayon..........." 12 | 13 | engine = pyttsx3.init('sapi5') 14 | voices = engine.getProperty('voices') 15 | engine.setProperty('voice', voices[0].id) 16 | 17 | 18 | # speak function will pronounce the string which is pass to it 19 | def speak(text): 20 | engine.say(text) 21 | engine.runAndWait() 22 | 23 | # This function will wish you as per the current time 24 | def wishMe(): 25 | hour = int(datetime.datetime.now().hour) 26 | 27 | if hour >= 0 and hour < 12: 28 | speak("Good Morning" + MASTER) 29 | 30 | elif hour >= 12 and hour < 18: 31 | speak("Good Afternoon" + MASTER) 32 | 33 | else: 34 | speak("Good Evening" + MASTER) 35 | 36 | speak("Hi!I'm Jarvis. How may I help you?") 37 | 38 | 39 | # Thish function will take comand from the microphone 40 | def takeCommand(): 41 | r = sr.Recognizer() 42 | with sr.Microphone() as source: 43 | print("Listening...") 44 | audio = r.listen(source) 45 | 46 | try: 47 | print("Recognizing...") 48 | query = r.recognize_google(audio, language='en-in') 49 | print(f"user said: {query}\n") 50 | 51 | except Exception as e: 52 | print("Say that again please") 53 | query = None 54 | 55 | return query 56 | 57 | 58 | def sendEmail(to, content): 59 | server = smtplib.SMTP('smtp.gmail.com', 587) 60 | server.ehlo() 61 | server.starttls() 62 | server.login('ayoniiiiiiii10@gmail.com', 'xxxxxxxx') 63 | server.sendmail("ayoniiiiii10@gmail.com", to, content) 64 | server.close() 65 | 66 | 67 | # Main program starts hear... 68 | speak(f"{MASTER} Initializing Jarvis...") 69 | wishMe() 70 | query = takeCommand() 71 | 72 | # Logic for executing tasks as per the query 73 | if 'wikipedia' in query.lower(): 74 | speak('searching wikipesea...') 75 | query = query.replace("wikipedia", "") 76 | results = wikipedia.summary(query, sentences=2) 77 | print(results) 78 | speak(results) 79 | 80 | elif 'open youtube' in query.lower(): 81 | # webbrowser.open("youtube.com") 82 | url = "youtube.com" 83 | chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s' 84 | webbrowser.get(chrome_path).open(url) 85 | print("opening youtube for You.....") 86 | 87 | elif 'open google' in query.lower(): 88 | # webbrowser.open("google.com") 89 | url = "google.com" 90 | chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s' 91 | webbrowser.get(chrome_path).open(url) 92 | elif 'i love you' in query.lower(): 93 | # speak("i love u too ayon....") 94 | speak("i love u too ") 95 | elif 'you are wast' in query.lower(): 96 | speak("I don't know it is ayon's mistake") 97 | print("I don't know it is ayon's mistake") 98 | elif 'Do you know my name' in query.lower(): 99 | speak("you are my best friend how can I not know you are name ayon....") 100 | 101 | elif 'open my blog' in query.lower(): 102 | # webbrowser.open("google.com") 103 | url = "https://www.google.com/search?q=karmakaraayon&sxsrf=ALeKk00zBkTefnqO8-dqFl6NtAVmd32-nA%3A1621777972093&ei=NF6qYOGoBbPjz7sP3c-SeA&oq=karmakaraa&gs_lcp=Cgdnd3Mtd2l6EAMYADIECCMQJzIECCMQJzIECAAQDTIECAAQDTIECAAQDTIGCAAQDRAKMgYIABANEAoyBAgAEA0yBggAEA0QCjIGCAAQDRAeOgcIABCwAxANOgUILhCRAjoFCC4QsQM6AgguOggILhCxAxCDAToFCAAQkQI6CAgAELEDEIMBOggIABCxAxCRAjoFCAAQsQM6AggAOggILhDHARCvAToECAAQCjoECAAQHlCKE1jXImC9LmgDcAB4AYAB1ASIAZAZkgELMC4zLjUuMS4wLjKYAQCgAQGqAQdnd3Mtd2l6yAEBwAEB&sclient=gws-wiz" 104 | chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s' 105 | webbrowser.get(chrome_path).open(url) 106 | 107 | elif 'my photos from google' in query.lower(): 108 | # webbrowser.open("google.com") 109 | url = "https://www.google.com/search?q=karmakaraayon&sxsrf=ALeKk02mPmg0nbbSucfv4PIId_gI07Wfaw:1621777979834&source=lnms&tbm=isch&sa=X&ved=2ahUKEwiXvpHj-d_wAhUlieYKHVUNC1UQ_AUoA3oECAEQBQ&biw=1707&bih=844&dpr=1.13" 110 | chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s' 111 | webbrowser.get(chrome_path).open(url) 112 | 113 | elif 'my profile' in query.lower(): 114 | # webbrowser.open("google.com") 115 | url = "https://www.linkedin.com/in/ayon-k/" 116 | chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s' 117 | webbrowser.get(chrome_path).open(url) 118 | 119 | elif 'open reddit' in query.lower(): 120 | # webbrowser.open("google.com") 121 | url = "reddit.com" 122 | chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s' 123 | webbrowser.get(chrome_path).open(url) 124 | 125 | elif 'play music' in query.lower(): 126 | songs_dir = "C:\\Users\\admin\\Music\\a" 127 | songs = os.listdir(songs_dir) 128 | print(songs) 129 | os.startfile(os.path.join(songs_dir, songs[0])) 130 | 131 | elif 'pdf' in query.lower(): 132 | url = "file:///E:/MY%20BAG/books/PythonNotesForProfessionals%20(1)%20(1)%20(1)%20(1)%20(2)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1).pdf" 133 | webbrowser.open_new(url) 134 | 135 | elif 'the time' in query.lower(): 136 | strTime = datetime.datetime.now().strftime("%H:%M:%S") 137 | speak(f"{MASTER} the time is {strTime}....................Come on..................... hurry up") 138 | 139 | elif 'open code' in query.lower(): 140 | codePath = "C:\\Users\\admin\\AppData\\Local\\Programs\\Microsoft VS Code\\code.exe" 141 | os.startfile(codePath) 142 | print("VS CODE in ayon's pc") 143 | elif 'game' in query.lower(): 144 | import random 145 | 146 | print("There will be 9 rounds") 147 | print("Who will score more he will be the winner") 148 | print("1)Rock\n2)Paper\n3)Scissor\n") 149 | 150 | score_of_user = 0 151 | score_of_system = 0 152 | 153 | 154 | def opt_of_system(): 155 | if (system == 1): 156 | print("Rock", end=" ") 157 | elif (system == 2): 158 | print("Paper", end=" ") 159 | elif (system == 3): 160 | print("Scissor", end=" ") 161 | 162 | 163 | def opt_of_user(): 164 | if (user == 1): 165 | print("Rock") 166 | elif (user == 2): 167 | print("Paper") 168 | elif (user == 3): 169 | print("Scissor") 170 | 171 | 172 | round_number = 1 173 | 174 | while (round_number <= 9): 175 | print("This is a", " round", round_number) 176 | 177 | user = int(input()) 178 | while (user >= 4): 179 | print("only Rock, Paper, Scissor \nNo 4th opt") 180 | print("cotinue") 181 | user = int(input()) 182 | 183 | system = random.randint(1, 3) 184 | if (system == user): 185 | opt_of_system() 186 | print(end=" ------ ") 187 | opt_of_user() 188 | print("Draw") 189 | print("this round is draw so no round is counted") 190 | print((10 - round_number), " Roundes left") 191 | 192 | 193 | elif ((system == 1 and user == 2) or (system == 2 and user == 3) or (system == 3 and user == 1)): 194 | opt_of_system() 195 | print(end=" ------ ") 196 | opt_of_user() 197 | print("✨-winner of this round-✨") 198 | score_of_user = score_of_user + 1 199 | print((9 - round_number), " Roundes left") 200 | print("U R score is", score_of_user) 201 | round_number = round_number + 1 202 | 203 | elif ((user == 1 and system == 2) or (user == 2 and system == 3) or (user == 3 and system == 1)): 204 | opt_of_system() 205 | print(end=" ------ ") 206 | opt_of_user() 207 | print("👎--Loose this round") 208 | score_of_system = score_of_system + 1 209 | print((9 - round_number), " Roundes left") 210 | print("U R score is", score_of_user) 211 | round_number = round_number + 1 212 | print(" ") 213 | 214 | if (score_of_user > score_of_system): 215 | print("👑----✨YOU ARE THE WINNER✨--🌀") 216 | 217 | elif (score_of_user < score_of_system): 218 | print("BETTER LUCK NEXT TIME") 219 | 220 | elif 'play music' in query.lower(): 221 | songs_dir = "C:\\Users\\admin\\Music\\a" 222 | songs = os.listdir(songs_dir) 223 | print(songs) 224 | os.startfile(os.path.join(songs_dir, songs[0])) 225 | --------------------------------------------------------------------------------