diff --git a/Final Report/Jarvis_Minor_Project_Report.pdf b/Final Report/Jarvis_Minor_Project_Report.pdf new file mode 100644 index 0000000..dbc1b22 Binary files /dev/null and b/Final Report/Jarvis_Minor_Project_Report.pdf differ diff --git a/Source Code of Jarvis- Your Personal Virtual Assistant/.gitignore b/Source Code of Jarvis- Your Personal Virtual Assistant/.gitignore new file mode 100644 index 0000000..ebfe9e6 --- /dev/null +++ b/Source Code of Jarvis- Your Personal Virtual Assistant/.gitignore @@ -0,0 +1,2 @@ +.vscode/ +__pycache__/ diff --git a/Source Code of Jarvis- Your Personal Virtual Assistant/Abstract.pdf b/Source Code of Jarvis- Your Personal Virtual Assistant/Abstract.pdf new file mode 100644 index 0000000..4a7076c Binary files /dev/null and b/Source Code of Jarvis- Your Personal Virtual Assistant/Abstract.pdf differ diff --git a/Source Code of Jarvis- Your Personal Virtual Assistant/Dockerfile b/Source Code of Jarvis- Your Personal Virtual Assistant/Dockerfile new file mode 100644 index 0000000..f09c8dd --- /dev/null +++ b/Source Code of Jarvis- Your Personal Virtual Assistant/Dockerfile @@ -0,0 +1,17 @@ +FROM winamd64/python:3-windowsservercore + +WORKDIR /usr/src/app + +COPY pywin32-300-cp39-cp39-win_amd64.whl . + +RUN python -m pip install -U pip +RUN pip install pywin32-300-cp39-cp39-win_amd64.whl +#pywin32 not installing in docker. + +COPY requirement.txt . +RUN pip3 install --no-cache-dir -r requirement.txt + +COPY . . +RUN pip install PyAudio-0.2.11-cp39-cp39-win_amd64.whl + +CMD ["python3", "./price_tracker.py"] diff --git a/Source Code of Jarvis- Your Personal Virtual Assistant/Jarvis_Minor_Project_Report.pdf b/Source Code of Jarvis- Your Personal Virtual Assistant/Jarvis_Minor_Project_Report.pdf new file mode 100644 index 0000000..dbc1b22 Binary files /dev/null and b/Source Code of Jarvis- Your Personal Virtual Assistant/Jarvis_Minor_Project_Report.pdf differ diff --git a/Source Code of Jarvis- Your Personal Virtual Assistant/PyAudio-0.2.11-cp39-cp39-win_amd64.whl b/Source Code of Jarvis- Your Personal Virtual Assistant/PyAudio-0.2.11-cp39-cp39-win_amd64.whl new file mode 100644 index 0000000..bc32d44 Binary files /dev/null and b/Source Code of Jarvis- Your Personal Virtual Assistant/PyAudio-0.2.11-cp39-cp39-win_amd64.whl differ diff --git a/Source Code of Jarvis- Your Personal Virtual Assistant/ReadMe.md b/Source Code of Jarvis- Your Personal Virtual Assistant/ReadMe.md new file mode 100644 index 0000000..77ed39e --- /dev/null +++ b/Source Code of Jarvis- Your Personal Virtual Assistant/ReadMe.md @@ -0,0 +1,130 @@ +# J.A.R.V.I.S (Just A Rather Very Intelligent System) + +## About Project + +### Jarvis is a virtual assistant like Siri and Alexa with additional face recognition based secruity mechanism. The assitant recognises speech and face of the user and responds accordingly. + +Various Features and tasks performed by this assistant are: + +1. It first wishes and greet the user by it's name according to the face recognized by the face recognizer. +2. It make use of Web Scraping to retreive the information directly from **Wikipedia** and can speak it directly by reading from Wiki. +3. It can report current date and time for you. +4. It can open Google, Youtube, Stackoverflow, Instagram, Facebook, Tinder and other **social media** Web applications for you by directly saying the name of the social media app. +5. It can open Python Interpreter(IDLE), Notepad, Calculator and other **System Softwares** for you. +6. It can open code editor or **IDE** like Vs-Code,Code-Blocks and any other IDE etc of your choice. +7. You can **send Email** to the intended user, It will be sended by personal email of Jarvis which can be configured according to the requirements. +8. Equipped with **face recognition.** +9. You **track prices** of the given product from the **E-Commerce** Websites according to the URL mentioned and can also tell it will be in your budget or not according to the settings done for the program. +10. You can also **track COVID-19 Vaccination Drives** near your location according to the district, state or precisily by updating your pincode in the setting.json file. + + +## How to Use + +To use this project on your system, follow these steps: + +1.Clone this repository onto your system by typing the following command on your Command Prompt: +``` +git clone https://github.com/JapeshBagga/J.A.R.V.I.S.git +``` +followed by: + +``` +cd J.A.R.V.I.S +``` + +2. Download all libaries using:: +``` +pip install -r requirements.txt +``` + +3. Now edit the **settings.json** file using your favorite code editor(Example: Sublime text editor, VSCode, Vim). + +4. Change ```budget:0``` value to your budget (Example: ```budget:999```) for price tracking & Update ```pin-code``` value according to your nearby postal code (Example: ```pin-code:161005```). + +5. Replace the link in **URL** with your target product link. (Example: ```url:'https://www.amazon.in/G731GT-Graphics-i5-9300H-Windows-G731GT-AU022T/dp/B07S36XJ8Q/'```) + +6. Change the **user agent** according to your [**user agent**](https://www.google.com/search?q=my+user+agent&oq=my+user&aqs=chrome.1.69i57j0l5.2294j1j7&sourceid=chrome&ie=UTF-8). (Example: ```headers = {"User-Agent": 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.75 Safari/537.36'} ```). +To know your user-agent just type the following on google: + ``` + my user agent + ``` + +7. Now save the file and run **main.py** by typing the following command on your Command Prompt: + +``` +python main.py +``` + +**Note:** 1. To open code editor of your choice and python interpreter(IDLE) you have to provide +path of your local directories in the source code to avoid error. +2. If there is any error regarding microphone or related to pyttsx3 or speech_recognition module follow these steps: + ```pip install pipwin ``` + then run this command + ```pip install PyAudio ``` + +3. In case you receive such errors: + +``` +No module named win32com.client +No module named win32 +No module named win32api +``` +Then, install pypiwin32 by typing the below command in the terminal : +``` +pip install pypiwin32. +``` +After successfully installing pyttsx3, import this module into your program. + + +## Implementation, Tools and Technologies + +- We have used ```Co-WIN Public API``` to fetch all the nearby vaccination drive locations and details. Co-WIN Public APIs allow any third-party application to access certain un-restricted information, that can be shared with its users. This is limited only to read access in Co-WIN. The extent of access will be limited and in case of any misuse impacting the performance of Co-WIN solution will result in blocking any such application and entities as per the policies of MoHFW and taking any other appropriate action in accordance with law. The appointment availability data is cached and may be up to 5 minutes old. Further, these APIs are subject to a rate limit of 100 API calls per 5 minutes per IP. Please consider these points while using the APIs in your application. + +- We have used ```Speech Recognition``` Library that is used for performing speech recognition, with support for several engines and APIs, both online and offline. + +- To make our J.A.R.V.I.S. talk, we will make a function called speak(). This function will take audio as an argument, and then it will pronounce it. We must supply audio so that we can pronounce it using the speak() function we made. For this We are using a module called ```pyttsx3``` It's a python library that will help us to convert text to speech. In short, it is a text-to-speech library. +It works offline, and it is compatible with Python 2 as well as Python 3. In this module we have various TTS engines namely + - sapi5 + - nsss + - espeak. +We have used ```sapi5``` application programming interface (API). It dramatically reduces the code overhead required for an application to use speech recognition and text-to-speech, making speech technology more accessible and robust for a wide range of applications. It Synthesize text strings and files into spoken audio using synthetic voices. Speech recognizers convert human spoken audio into readable text strings and files. +Applications that use SAPI include Microsoft Office, Microsoft Agent and Microsoft Speech Server. +In general, all versions of the API have been designed such that a software developer can write an application to perform speech recognition and synthesis by using a standard set of interfaces, accessible from a variety of programming languages. In addition, it is possible for a 3rd-party company to produce their own Speech Recognition and Text-To-Speech engines or adapt existing engines to work with SAPI. In principle, as long as these engines conform to the defined interfaces they can be used instead of the Microsoft-supplied engines. + +In general, the Speech API is a freely redistributable component which can be shipped with any Windows application that wishes to use speech technology. Many versions (although not all) of the speech recognition and synthesis engines are also freely redistributable. + + +- To Recognize and manipulate faces from Python or from the command line with the world’s simplest face recognition library ```Face Recognition``` built using dlib’s state-of-the-art face recognition built with deep learning. The model has an accuracy of 99.38% on the Labeled Faces in the Wild benchmark. This also provides a simple face_recognition command line tool that lets +you do face recognition on a folder of images from the command line! Dlib is a modern C++ toolkit containing machine learning algorithms and tools for creating complex software in C++ to solve real world problems. It is used in both industry and academia in a wide range of domains including robotics, embedded devices, mobile phones, and large high performance computing environments. Dlib's open source licensing allows you to use it in any application, free of charge. It internally uses OpenCV and Numpy for performing Image recognition or Processing. + +- For Web Scraping, we have used ```Beautiful Soup``` It is a library that makes it easy to scrape information from web pages. It sits atop an HTML or XML parser, providing Pythonic idioms for iterating, searching, and modifying the parse tree. +-- + + +## BiblioGraphy +- https://pyttsx3.readthedocs.io/en/latest/ +- https://apisetu.gov.in/about.php +- https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms723627(v=vs.85) +- https://en.wikipedia.org/wiki/Microsoft_Speech_API +- http://dlib.net/ +- https://www.crummy.com/software/BeautifulSoup/bs4/doc/ + + +--- + +## To Run this program on Startup +### Linux +https://help.ubuntu.com/stable/ubuntu-help/startup-applications.html.en + +### Windows +https://support.microsoft.com/en-in/help/4026268/windows-10-change-startup-apps + +--- + +### The Project is now ready to use !! + + +### [![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Fgjbae1212%2Fhit-counter&count_bg=%23313129&title_bg=%231F1F1F&icon=purescript.svg&icon_color=%23FFDD00&title=Repository+Vists&edge_flat=true)](https://hits.seeyoufarm.com) + + +### [![forthebadge](https://forthebadge.com/images/badges/made-with-python.svg)](https://forthebadge.com) diff --git a/Source Code of Jarvis- Your Personal Virtual Assistant/Synopsis_Jarvis_Minor_Project.pdf b/Source Code of Jarvis- Your Personal Virtual Assistant/Synopsis_Jarvis_Minor_Project.pdf new file mode 100644 index 0000000..0022ac4 Binary files /dev/null and b/Source Code of Jarvis- Your Personal Virtual Assistant/Synopsis_Jarvis_Minor_Project.pdf differ diff --git a/Source Code of Jarvis- Your Personal Virtual Assistant/Training_images/Daman.jpg b/Source Code of Jarvis- Your Personal Virtual Assistant/Training_images/Daman.jpg new file mode 100644 index 0000000..473381c Binary files /dev/null and b/Source Code of Jarvis- Your Personal Virtual Assistant/Training_images/Daman.jpg differ diff --git a/Source Code of Jarvis- Your Personal Virtual Assistant/Training_images/Japesh.jpg b/Source Code of Jarvis- Your Personal Virtual Assistant/Training_images/Japesh.jpg new file mode 100644 index 0000000..05a135b Binary files /dev/null and b/Source Code of Jarvis- Your Personal Virtual Assistant/Training_images/Japesh.jpg differ diff --git a/Source Code of Jarvis- Your Personal Virtual Assistant/Training_images/Simple.jpg b/Source Code of Jarvis- Your Personal Virtual Assistant/Training_images/Simple.jpg new file mode 100644 index 0000000..300445a Binary files /dev/null and b/Source Code of Jarvis- Your Personal Virtual Assistant/Training_images/Simple.jpg differ diff --git a/Source Code of Jarvis- Your Personal Virtual Assistant/face_recognizer.py b/Source Code of Jarvis- Your Personal Virtual Assistant/face_recognizer.py new file mode 100644 index 0000000..fd66310 --- /dev/null +++ b/Source Code of Jarvis- Your Personal Virtual Assistant/face_recognizer.py @@ -0,0 +1,83 @@ +import cv2 +import os +import numpy as np +import face_recognition + +#Face Recognization Code +def findEncodings(images): + encodeList = [] + for img in images: + img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) + encode = face_recognition.face_encodings(img)[0] + encodeList.append(encode) + return encodeList + +def markAttendance(name): + with open('C:/Users/japba/Desktop/Projects/Jarvis/Attendance.csv', 'r+') as f: + myDataList = f.readlines() + + nameList = [] + for line in myDataList: + entry = line.split(',') + nameList.append(entry[0]) + if name not in nameList: + now = datetime.now() + dtString = now.strftime('%H:%M:%S') + f.writelines(f'\n{name},{dtString}') + + #### FOR CAPTURING SCREEN RATHER THAN WEBCAM + # def captureScreen(bbox=(300,300,690+300,530+300)): + # capScr = np.array(ImageGrab.grab(bbox)) + # capScr = cv2.cvtColor(capScr, cv2.COLOR_RGB2BGR) + # return capScr + +def faceRecognizer(): + path = 'C:/Users/japba/Desktop/Projects/Jarvis/Training_images' + images = [] + classNames = [] + myList = os.listdir(path) + #print(myList) + for cl in myList: + curImg = cv2.imread(f'{path}/{cl}') + images.append(curImg) + classNames.append(os.path.splitext(cl)[0]) + print(classNames) + + encodeListKnown = findEncodings(images) + cap = cv2.VideoCapture(0) + print("Recognizing Face...") + + while True: + success, img = cap.read() + # img = captureScreen() + imgS = cv2.resize(img, (0, 0), None, 0.25, 0.25) + imgS = cv2.cvtColor(imgS, cv2.COLOR_BGR2RGB) + + facesCurFrame = face_recognition.face_locations(imgS) + encodesCurFrame = face_recognition.face_encodings(imgS, facesCurFrame) + + for encodeFace, faceLoc in zip(encodesCurFrame, facesCurFrame): + matches = face_recognition.compare_faces(encodeListKnown, encodeFace) + faceDis = face_recognition.face_distance(encodeListKnown, encodeFace) + # print(faceDis) + matchIndex = np.argmin(faceDis) + + if matches[matchIndex]: + name = classNames[matchIndex].upper() + y1, x2, y2, x1 = faceLoc + y1, x2, y2, x1 = y1 * 4, x2 * 4, y2 * 4, x1 * 4 + cv2.rectangle(img, (x1, y1), (x2, y2), (0, 255, 0), 2) + cv2.rectangle(img, (x1, y2 - 35), (x2, y2), (0, 255, 0), cv2.FILLED) + cv2.putText(img, name, (x1 + 6, y2 - 6), cv2.FONT_HERSHEY_COMPLEX, 1, (255, 255, 255), 2) + #markAttendance(name) + print("Matched") + return name + + #cv2.imshow('Webcam', img) + #if cv2.waitKey(1) & 0xFF == ord('q'): + # break + + +if __name__ == "__main__": + faceRecognizer() + diff --git a/Source Code of Jarvis- Your Personal Virtual Assistant/jarvis.py b/Source Code of Jarvis- Your Personal Virtual Assistant/jarvis.py new file mode 100644 index 0000000..1363dde --- /dev/null +++ b/Source Code of Jarvis- Your Personal Virtual Assistant/jarvis.py @@ -0,0 +1,189 @@ +import pyttsx3 +import speech_recognition as sr +import datetime +import wikipedia +import webbrowser +import os +import smtplib +import random +import price_tracker +import vaccine_tracker + +#Initializing Speech Recognition variables +engine = pyttsx3.init('sapi5') # object creation +voices = engine.getProperty('voices') #getting details of current voice +engine.setProperty('rate', 175) # setting up new voice rate; Default is 200 +engine.setProperty('voice', voices[1].id) #changing voices[index] change voice tune o for male and 1 for female + +def speak(audio): + print(audio) + engine.say(audio) + engine.runAndWait() + +def wishMe(name): + hour = int(datetime.datetime.now().hour) + if hour>=0 and hour<12: + speak("Good Morning!"+name) + + elif hour>=12 and hour<18: + speak("Good Afternoon!"+name) + + else: + speak("Good Evening! "+name) + speak("Hi, Jarvis Here, How may I help You?") + +def takeCommand(): + r = sr.Recognizer() + with sr.Microphone() as source: + speak("I'm Listening...") + r.energy_threshold=800 + r.pause_threshold = 1 + audio = r.listen(source) + try: + speak("Okay! ") + query = r.recognize_google(audio, language='en-in') + print(f"User said: {query}\n") + except Exception as e: + speak("Say that again please...") + return "None" + return query + +def sendEmail(to, content): + server = smtplib.SMTP('smtp.gmail.com', 587) + server.ehlo() + server.starttls() + server.login('email@gmail.com', 'your-password') + server.sendmail('email@gmail.com', to, content) + server.close() + +def listenCommand(): + while True: + query = takeCommand().lower() + # Change the browser path according to your PC + web_browser_path= "C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe %s" + if "bye" in query: + speak("Thank You Sir, have a nice day") + exit() + if 'open youtube' in query: + webbrowser.get(web_browser_path).open("youtube.com") + + elif 'open g n e website' in query: + webbrowser.get(web_browser_path).open("www.gndec.ac.in") + + elif 'open it department website' in query: + webbrowser.get(web_browser_path).open("it.gndec.ac.in") + + elif 'open google' in query: + webbrowser.get(web_browser_path).open("google.com") + + elif 'open w3schools' in query: + webbrowser.get(web_browser_path).open("w3schools.com") + + elif 'the weather' in query: + webbrowser.get(web_browser_path).open("https://www.google.com/search?q=weather") + + elif 'open notepad' in query: + os.system('notepad') + + elif 'open calculator' in query: + os.system('start Calculator:') + + elif 'open edge' in query: + codePath = "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe" + os.startfile(codePath) + + elif 'open gallery' in query: + codePath = "D://Pins" + os.startfile(codePath) + + elif 'play music' in query: + music_dir = 'D://Music' + songs = os.listdir(music_dir) + randomsongs = random.choice(songs) + os.startfile(os.path.join(music_dir, randomsongs)) + + elif query.startswith('google'): + speak('Searching google...') + query1 = query.replace("google ", "") + query2 = query1.replace(" ","+") + webbrowser.get(web_browser_path).open(f"https://www.youtube.com/search?q={query2}") + + elif query.startswith('youtube'): + speak('Searching YouTube...') + query1 = query.replace("youtube ", "") + query2 = query1.replace(" ","+") + webbrowser.get(web_browser_path).open(f"https://www.youtube.com/results?search_query={query2}") + + elif query.startswith('wikipedia'): + speak('Searching Wikipedia...') + query = query.replace("wikipedia", "") + results = wikipedia.summary(query, sentences=2) + speak("According to Wikipedia") + speak(results) + + elif query.startswith('translate'): + query1 = query.replace(" ","+") + webbrowser.get(web_browser_path).open(f"https://www.google.com/search?q={query1}") + + elif 'time' in query: + strTime = datetime.datetime.now().strftime("%H:%M:%S") + speak(f"Sir, the time is {strTime}") + + elif 'date and time' in query: + strDate = datetime.datetime.now.strftime("%m/%d/%Y, %H:%M:%S") + speak(f"Sir, the date and time is {strDate}") + + elif 'open code' in query: + codePath = "f://project//jarvis.py" + os.startfile(codePath) + + elif 'price tracker' in query: + try: + result = price_tracker.run() + speak(result) + except Exception as e: + print(e) + speak("Sorry! I am not able to run price tracker!") + elif 'vaccine tracker' in query: + try: + result = vaccine_tracker.findByPin() + if type(result) is list: + intro = "There are {} Vaccination Drives ongoing near your location".format(len(result)) + speak(intro) + n = 1 + for res in result: + speak(n) + speak(res) + n+=1 + else: + speak(result) + except Exception as e: + print(e) + speak("Sorry! I am not able to run vaccine tracker!") + + elif 'send email to' in query: + try: + speak("To whom? ") + to = takeCommand() + speak("What should I say?") + content = takeCommand() + 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 "none" in query: + continue + else: + speak('I\'m not aware, Should I Search it on google?') + cmd = takeCommand() + if "yes" in cmd: + speak('Googling'+query) + query2 = query.replace(" ", "+") + webbrowser.get(web_browser_path).open(f"https://www.google.com/search?q={query2}") + speak("Anything else? ") + +# Main function +if __name__ == '__main__': + wishMe("") # Give your name + listenCommand() \ No newline at end of file diff --git a/Source Code of Jarvis- Your Personal Virtual Assistant/main.py b/Source Code of Jarvis- Your Personal Virtual Assistant/main.py new file mode 100644 index 0000000..35369f0 --- /dev/null +++ b/Source Code of Jarvis- Your Personal Virtual Assistant/main.py @@ -0,0 +1,10 @@ +import os +import jarvis +import face_recognizer + + +if __name__ == "__main__": + name = face_recognizer.faceRecognizer() + jarvis.wishMe(name) + jarvis.listenCommand() + diff --git a/Source Code of Jarvis- Your Personal Virtual Assistant/price_tracker.py b/Source Code of Jarvis- Your Personal Virtual Assistant/price_tracker.py new file mode 100644 index 0000000..a704070 --- /dev/null +++ b/Source Code of Jarvis- Your Personal Virtual Assistant/price_tracker.py @@ -0,0 +1,85 @@ +import requests +from bs4 import BeautifulSoup +import os +import time +import json + +#Opening The Settings.json file +with open('c:/Users/japba/Desktop/Projects/Jarvis/settings.json','r') as file: + settings = json.load(file) + +URL = settings['url'] # the URL we are going to use +my_price = settings['budget'] # Set your budget +headers = {"User-Agent": settings['user-agent']} # Google "My User Agent" And Replace It +currency_symbols = ['€', '£', '$', "¥", "HK$", "₹", "¥", ","] # initializing Currency Symbols to substract it from our string + +#Checking the price +def checking_price(): + page = requests.get(URL, headers=headers) + soup = BeautifulSoup(page.content, 'html.parser') + + if "amazon" in URL: + try: + #Finding the elements + product_title = soup.find(id="productTitle").get_text().strip() + product_price = soup.find(id="priceblock_ourprice").get_text() + + # using replace() to remove currency symbols + for i in currency_symbols : + product_price = product_price.replace(i, '') + + #Converting the string to integer + product_price = int(float(product_price)) + print("The Product Name is:" ,product_title.strip()) + print("The Price is:" ,product_price) + + # checking the price + if(product_price