Skip to content

Commit 4b7636f

Browse files
authored
Merge pull request larymak#346 from prathu10/main
Jarvis
2 parents 37f05ec + ee95e50 commit 4b7636f

File tree

2,497 files changed

+300377
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,497 files changed

+300377
-0
lines changed

OTHERS/Jarvis/Iron_Template_1.gif

944 KB
Loading

OTHERS/Jarvis/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
The project aims to develop a desktop assistant using Python that can assist users
2+
in performing a variety of tasks, streamline their workflow, and provide useful information.
3+
The desktop assistant should serve as a virtual helper, enhancing user productivity and convenience on a desktop or laptop computer.
4+
The desktop assistant should have a user-friendly interface and voice-based interactions. Users should be able to type commands or speak to the assistant to initiate actions.
5+
Implement voice recognition capabilities to allow users to communicate with the assistant using natural language.
6+
The assistant should be capable of automating common desktop tasks such as opening applications, creating files, searching information , setting reminders.

OTHERS/Jarvis/initial.gif

1.25 MB
Loading

OTHERS/Jarvis/jarvis.py

+275
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,275 @@
1+
from email.mime import audio
2+
from importlib.resources import path
3+
from logging import exception
4+
from random import Random, random
5+
from re import S
6+
import sys
7+
from typing_extensions import Self
8+
import pyttsx3
9+
import speech_recognition as sr
10+
import datetime
11+
import os
12+
import cv2
13+
import random
14+
from requests import get
15+
import wikipedia
16+
import webbrowser
17+
import pywhatkit as kit
18+
import smtplib
19+
import sys
20+
import pyjokes
21+
from PyQt5 import QtWidgets, QtCore, QtGui
22+
from PyQt5.QtCore import QTimer, QTime, QDate, Qt
23+
from PyQt5.QtGui import QMovie
24+
from PyQt5.QtCore import *
25+
from PyQt5.QtGui import *
26+
from PyQt5.QtWidgets import *
27+
from PyQt5.uic import loadUiType
28+
from jarvisUi import Ui_jarvisUi
29+
30+
31+
engine = pyttsx3.init('sapi5')
32+
voices = engine.getProperty('voices')
33+
print(voices[0].id)
34+
engine.setProperty('voices', voices[0].id)
35+
36+
37+
# text to speech
38+
def speak(audio):
39+
engine.say(audio)
40+
print(audio)
41+
engine.runAndWait()
42+
43+
44+
# wish function
45+
def wish():
46+
hour = int(datetime.datetime.now().hour)
47+
#tt = time.strftime("%I:%M:%p")
48+
49+
if hour >= 0 and hour <= 12:
50+
speak("Good morning,sir")
51+
elif hour > 12 and hour < 18:
52+
speak("Good afternoon,sir")
53+
else:
54+
speak("Good Evening,sir")
55+
speak("I am Jarvis sir,How can I help you?")
56+
57+
58+
# to define send email
59+
def sendEmail(to, content):
60+
server = smtplib.SMTP('smtp.gmail.com', 587)
61+
server.ehlo()
62+
server.starttls()
63+
server.login('[email protected]', 'Tata@1234')
64+
server.sendmail('[email protected]', to, content)
65+
server.close()
66+
67+
# to convert voice into text
68+
class Mainthread(QThread):
69+
def __init__(self):
70+
super(Mainthread,self).__init__()
71+
72+
def run(self):
73+
self.TaskExecution()
74+
75+
def takecommand(self):
76+
77+
r = sr.Recognizer()
78+
with sr.Microphone() as source:
79+
print("Listening...")
80+
r.pause_threshold = 1
81+
r.adjust_for_ambient_noise(source)
82+
audio = r.listen(source, timeout=2, phrase_time_limit=5)
83+
84+
try:
85+
print("Recognizng..")
86+
query = r.recognize_google(audio, language='en-in')
87+
print(f"user said: {query}")
88+
89+
except exception as e:
90+
speak("could you please repeat...")
91+
return "none"
92+
query = query.lower()
93+
return query
94+
95+
#if __name__ == "__main__":
96+
def TaskExecution(self):
97+
#def start():
98+
wish()
99+
100+
while True:
101+
102+
self.query = self.takecommand()
103+
104+
# logic building for tasks
105+
106+
if "open notepad" in self.query:
107+
npath = "C:\\Windows\\System32\\notepad.exe"
108+
os.startfile(npath)
109+
110+
elif "open adobe reader" in self.query:
111+
apath = "C:\\Program Files (x86)\\Adobe\\Reader 10.0\\Reader\\AcroRd32.exe"
112+
os.startfile(apath)
113+
114+
elif "open command prompt" in self.query:
115+
os.system("start cmd")
116+
117+
elif "open camera" in self.query:
118+
cap = cv2.VideoCapture(0)
119+
while True:
120+
ret, img = cap.read()
121+
cv2.inshow('webcam', img)
122+
k = cv2.waitKey(50)
123+
if k == 27:
124+
break
125+
cap.release()
126+
cv2.destroyAllWindows()
127+
128+
elif "play music" in self.query:
129+
music_dir = "C:\\Users\\vijay\\Music"
130+
songs = os.listdir(music_dir)
131+
rd = Random.choice(songs)
132+
# for song in songs:
133+
# if song.endswith('.mp3'):
134+
os.startfile(os.path.join(music_dir, rd))
135+
# os.startfile(os.path.join(music_dir,song))
136+
137+
elif "ip address" in self.query:
138+
ip = get('https://api.ipify.org').text
139+
speak(f"your IP Address is {ip}")
140+
141+
elif "wikipedia" in self.query:
142+
speak("Searching wikipedia...")
143+
query = query.replace("wikipedia", "")
144+
result = wikipedia.summary(query, sentence=2)
145+
speak("According to wikipedia")
146+
speak(result)
147+
# print(result)
148+
149+
elif "open youtube" in self.query:
150+
webbrowser.open("www.youtube.com")
151+
152+
elif "open facebook" in self.query:
153+
webbrowser.open("www.facebook.com")
154+
155+
elif "open stack overflow" in self.query:
156+
webbrowser.open("www.stackoverflow.com")
157+
158+
elif "open google" in self.query:
159+
# to search something specific on google
160+
speak("Sir what should i search on google")
161+
cm = self.takecommand()
162+
webbrowser.open(f"{cm}")
163+
164+
elif "send message" in self.query:
165+
#speak("Sir,to whom should i send message")
166+
#wmsg = takecommand().lower()
167+
# 2.25 is time at which you send
168+
kit.sendwhatmsg("+919920309439", "this is a testing message", 2.25)
169+
170+
elif "play songs on youtube" in self.query:
171+
speak("Sir what should i play on youtube")
172+
play = self.takecommand()
173+
kit.playonyt(f"{play}")
174+
175+
elif "send email" in self.query:
176+
try:
177+
speak("what should i say?")
178+
content = self.takecommand()
179+
180+
sendEmail(to, content)
181+
speak("Email has been sent")
182+
183+
except exception as e:
184+
print(e)
185+
speak("sorry sir, i am not able to send the email")
186+
187+
# to close application
188+
elif "close notepad" in self.query:
189+
speak("okay sir,closing notepad")
190+
os.system("taskkill /f/im notepad.exe")
191+
192+
elif "set alarm" in self.query:
193+
nn = int(datetime.datetime.now().hour)
194+
if nn == 11:
195+
music_dir = "Libraries\\Music"
196+
songs = os.listdir(music_dir)
197+
os.startfile(os.path.join(music_dir, songs[0]))
198+
199+
elif "joke" in self.query:
200+
joke = pyjokes.get_joke()
201+
speak(joke)
202+
203+
elif "shutdown the system" in self.query:
204+
os.system("shutdown /s /t 5")
205+
206+
elif "restart the system" in self.query:
207+
os.system("shutdown /r /t 5")
208+
209+
elif "sleep the system" in self.query:
210+
os.system("rundll32.exe powrprof.dll,SetSuspendState 0,1,0")
211+
212+
elif "thank you" in self.query:
213+
speak("thankyou sir,have a good day")
214+
sys.exit()
215+
216+
speak("sir,do you have any other work")
217+
218+
219+
220+
#if __name__ == "__main__" :
221+
# TaskExecution()
222+
223+
startExecution = Mainthread()
224+
225+
class Main(QMainWindow):
226+
def __init__(self):
227+
super().__init__()
228+
self.ui = Ui_jarvisUi()
229+
self.ui.setupUi(self)
230+
self.ui.pushButton.clicked.connect(self.startTask)
231+
self.ui.pushButton_2.clicked.connect(self.close)
232+
233+
def startTask(self):
234+
#self.ui.movie = QtGui.QMovie("Black_Template.jpg")
235+
#self.ui.label.setMovie(self.ui.movie)
236+
#self.ui.movie.start()
237+
self.ui.movie = QtGui.QMovie("Iron_Template_1.gif")
238+
self.ui.label_2.setMovie(self.ui.movie)
239+
self.ui.movie.start()
240+
self.ui.movie = QtGui.QMovie("jarvis_jj.gif")
241+
self.ui.label_3.setMovie(self.ui.movie)
242+
self.ui.movie.start()
243+
self.ui.movie = QtGui.QMovie("initial.gif")
244+
self.ui.label_4.setMovie(self.ui.movie)
245+
self.ui.movie.start()
246+
self.ui.movie = QtGui.QMovie("Health_Template.gif")
247+
self.ui.label_5.setMovie(self.ui.movie)
248+
self.ui.movie.start()
249+
self.ui.movie = QtGui.QMovie("B.G_Template_1.gif")
250+
self.ui.label_6.setMovie(self.ui.movie)
251+
self.ui.movie.start()
252+
timer = QTimer(self)
253+
timer.timeout.connect(self.showTime)
254+
timer.start(1000)
255+
startExecution.start()
256+
257+
def showTime(self):
258+
current_time = QTime.currentTime()
259+
current_date = QDate.currentDate()
260+
label_time = current_time.toString('hh:mm:ss')
261+
label_date = current_date.toString(Qt.ISODate)
262+
self.ui.textBrowser.setText(label_date)
263+
self.ui.textBrowser_2.setText(label_time)
264+
265+
266+
267+
app = QApplication(sys.argv)
268+
jarvis = Main()
269+
jarvis.show()
270+
exit(app.exec_())
271+
272+
273+
274+
275+

OTHERS/Jarvis/jarvis.zip

2.61 KB
Binary file not shown.

OTHERS/Jarvis/jarvisUi.py

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# Form implementation generated from reading ui file 'jarvisUi.ui'
4+
#
5+
# Created by: PyQt5 UI code generator 5.15.4
6+
#
7+
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
8+
# run again. Do not edit this file unless you know what you are doing.
9+
10+
11+
from PyQt5 import QtCore, QtGui, QtWidgets
12+
13+
14+
class Ui_jarvisUi(object):
15+
def setupUi(self, jarvisUi):
16+
jarvisUi.setObjectName("jarvisUi")
17+
jarvisUi.resize(997, 533)
18+
self.centralwidget = QtWidgets.QWidget(jarvisUi)
19+
self.centralwidget.setObjectName("centralwidget")
20+
self.label = QtWidgets.QLabel(self.centralwidget)
21+
self.label.setGeometry(QtCore.QRect(-170, -10, 1211, 541))
22+
self.label.setText("")
23+
self.label.setPixmap(QtGui.QPixmap("Black_Template.jpg"))
24+
self.label.setScaledContents(True)
25+
self.label.setObjectName("label")
26+
self.label_2 = QtWidgets.QLabel(self.centralwidget)
27+
self.label_2.setGeometry(QtCore.QRect(630, 10, 371, 281))
28+
self.label_2.setText("")
29+
self.label_2.setPixmap(QtGui.QPixmap("Iron_Template_1.gif"))
30+
self.label_2.setScaledContents(True)
31+
self.label_2.setObjectName("label_2")
32+
self.label_3 = QtWidgets.QLabel(self.centralwidget)
33+
self.label_3.setGeometry(QtCore.QRect(20, 180, 261, 181))
34+
self.label_3.setText("")
35+
self.label_3.setPixmap(QtGui.QPixmap("jarvis_jj.gif"))
36+
self.label_3.setScaledContents(True)
37+
self.label_3.setObjectName("label_3")
38+
self.label_4 = QtWidgets.QLabel(self.centralwidget)
39+
self.label_4.setGeometry(QtCore.QRect(16, 12, 521, 181))
40+
self.label_4.setText("")
41+
self.label_4.setPixmap(QtGui.QPixmap("initial.gif"))
42+
self.label_4.setScaledContents(True)
43+
self.label_4.setObjectName("label_4")
44+
self.label_5 = QtWidgets.QLabel(self.centralwidget)
45+
self.label_5.setGeometry(QtCore.QRect(20, 370, 281, 151))
46+
self.label_5.setText("")
47+
self.label_5.setPixmap(QtGui.QPixmap("Health_Template.gif"))
48+
self.label_5.setScaledContents(True)
49+
self.label_5.setObjectName("label_5")
50+
self.label_6 = QtWidgets.QLabel(self.centralwidget)
51+
self.label_6.setGeometry(QtCore.QRect(730, 320, 251, 181))
52+
self.label_6.setText("")
53+
self.label_6.setPixmap(QtGui.QPixmap("B.G_Template_1.gif"))
54+
self.label_6.setScaledContents(True)
55+
self.label_6.setObjectName("label_6")
56+
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
57+
self.pushButton.setGeometry(QtCore.QRect(420, 360, 101, 51))
58+
self.pushButton.setStyleSheet("color: rgb(0, 0, 255);\n"
59+
"background-color: rgb(85, 255, 255);\n"
60+
"font: 14pt \"MS UI Gothic\";")
61+
self.pushButton.setObjectName("pushButton")
62+
self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget)
63+
self.pushButton_2.setGeometry(QtCore.QRect(530, 360, 101, 51))
64+
self.pushButton_2.setStyleSheet("color: rgb(0, 0, 255);\n"
65+
"background-color: rgb(85, 255, 255);\n"
66+
"font: 14pt \"MS UI Gothic\";\n"
67+
"")
68+
self.pushButton_2.setObjectName("pushButton_2")
69+
self.textBrowser = QtWidgets.QTextBrowser(self.centralwidget)
70+
self.textBrowser.setGeometry(QtCore.QRect(330, 470, 191, 51))
71+
self.textBrowser.setStyleSheet("background-color: transparent;\n"
72+
"border-radius:none;\n"
73+
"color:white;\n"
74+
"font-size:20px;")
75+
self.textBrowser.setObjectName("textBrowser")
76+
self.textBrowser_2 = QtWidgets.QTextBrowser(self.centralwidget)
77+
self.textBrowser_2.setGeometry(QtCore.QRect(520, 470, 191, 51))
78+
self.textBrowser_2.setStyleSheet("background-color: transparent;\n"
79+
"border-radius:none;\n"
80+
"color:white;\n"
81+
"font-size:20px;")
82+
self.textBrowser_2.setObjectName("textBrowser_2")
83+
jarvisUi.setCentralWidget(self.centralwidget)
84+
85+
self.retranslateUi(jarvisUi)
86+
QtCore.QMetaObject.connectSlotsByName(jarvisUi)
87+
88+
def retranslateUi(self, jarvisUi):
89+
_translate = QtCore.QCoreApplication.translate
90+
jarvisUi.setWindowTitle(_translate("jarvisUi", "MainWindow"))
91+
self.pushButton.setText(_translate("jarvisUi", "START"))
92+
self.pushButton_2.setText(_translate("jarvisUi", "EXIT"))
93+
94+
95+
if __name__ == "__main__":
96+
import sys
97+
app = QtWidgets.QApplication(sys.argv)
98+
jarvisUi = QtWidgets.QMainWindow()
99+
ui = Ui_jarvisUi()
100+
ui.setupUi(jarvisUi)
101+
jarvisUi.show()
102+
sys.exit(app.exec_())

0 commit comments

Comments
 (0)