Skip to content

Jarvis #346

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file added OTHERS/Jarvis/Iron_Template_1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions OTHERS/Jarvis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
The project aims to develop a desktop assistant using Python that can assist users
in performing a variety of tasks, streamline their workflow, and provide useful information.
The desktop assistant should serve as a virtual helper, enhancing user productivity and convenience on a desktop or laptop computer.
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.
Implement voice recognition capabilities to allow users to communicate with the assistant using natural language.
The assistant should be capable of automating common desktop tasks such as opening applications, creating files, searching information , setting reminders.
Binary file added OTHERS/Jarvis/initial.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
275 changes: 275 additions & 0 deletions OTHERS/Jarvis/jarvis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,275 @@
from email.mime import audio
from importlib.resources import path
from logging import exception
from random import Random, random
from re import S
import sys
from typing_extensions import Self
import pyttsx3
import speech_recognition as sr
import datetime
import os
import cv2
import random
from requests import get
import wikipedia
import webbrowser
import pywhatkit as kit
import smtplib
import sys
import pyjokes
from PyQt5 import QtWidgets, QtCore, QtGui
from PyQt5.QtCore import QTimer, QTime, QDate, Qt
from PyQt5.QtGui import QMovie
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.uic import loadUiType
from jarvisUi import Ui_jarvisUi


engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
print(voices[0].id)
engine.setProperty('voices', voices[0].id)


# text to speech
def speak(audio):
engine.say(audio)
print(audio)
engine.runAndWait()


# wish function
def wish():
hour = int(datetime.datetime.now().hour)
#tt = time.strftime("%I:%M:%p")

if hour >= 0 and hour <= 12:
speak("Good morning,sir")
elif hour > 12 and hour < 18:
speak("Good afternoon,sir")
else:
speak("Good Evening,sir")
speak("I am Jarvis sir,How can I help you?")


# to define send email
def sendEmail(to, content):
server = smtplib.SMTP('smtp.gmail.com', 587)
server.ehlo()
server.starttls()
server.login('[email protected]', 'Tata@1234')
server.sendmail('[email protected]', to, content)
server.close()

# to convert voice into text
class Mainthread(QThread):
def __init__(self):
super(Mainthread,self).__init__()

def run(self):
self.TaskExecution()

def takecommand(self):

r = sr.Recognizer()
with sr.Microphone() as source:
print("Listening...")
r.pause_threshold = 1
r.adjust_for_ambient_noise(source)
audio = r.listen(source, timeout=2, phrase_time_limit=5)

try:
print("Recognizng..")
query = r.recognize_google(audio, language='en-in')
print(f"user said: {query}")

except exception as e:
speak("could you please repeat...")
return "none"
query = query.lower()
return query

#if __name__ == "__main__":
def TaskExecution(self):
#def start():
wish()

while True:

self.query = self.takecommand()

# logic building for tasks

if "open notepad" in self.query:
npath = "C:\\Windows\\System32\\notepad.exe"
os.startfile(npath)

elif "open adobe reader" in self.query:
apath = "C:\\Program Files (x86)\\Adobe\\Reader 10.0\\Reader\\AcroRd32.exe"
os.startfile(apath)

elif "open command prompt" in self.query:
os.system("start cmd")

elif "open camera" in self.query:
cap = cv2.VideoCapture(0)
while True:
ret, img = cap.read()
cv2.inshow('webcam', img)
k = cv2.waitKey(50)
if k == 27:
break
cap.release()
cv2.destroyAllWindows()

elif "play music" in self.query:
music_dir = "C:\\Users\\vijay\\Music"
songs = os.listdir(music_dir)
rd = Random.choice(songs)
# for song in songs:
# if song.endswith('.mp3'):
os.startfile(os.path.join(music_dir, rd))
# os.startfile(os.path.join(music_dir,song))

elif "ip address" in self.query:
ip = get('https://api.ipify.org').text
speak(f"your IP Address is {ip}")

elif "wikipedia" in self.query:
speak("Searching wikipedia...")
query = query.replace("wikipedia", "")
result = wikipedia.summary(query, sentence=2)
speak("According to wikipedia")
speak(result)
# print(result)

elif "open youtube" in self.query:
webbrowser.open("www.youtube.com")

elif "open facebook" in self.query:
webbrowser.open("www.facebook.com")

elif "open stack overflow" in self.query:
webbrowser.open("www.stackoverflow.com")

elif "open google" in self.query:
# to search something specific on google
speak("Sir what should i search on google")
cm = self.takecommand()
webbrowser.open(f"{cm}")

elif "send message" in self.query:
#speak("Sir,to whom should i send message")
#wmsg = takecommand().lower()
# 2.25 is time at which you send
kit.sendwhatmsg("+919920309439", "this is a testing message", 2.25)

elif "play songs on youtube" in self.query:
speak("Sir what should i play on youtube")
play = self.takecommand()
kit.playonyt(f"{play}")

elif "send email" in self.query:
try:
speak("what should i say?")
content = self.takecommand()
to = "[email protected]"
sendEmail(to, content)
speak("Email has been sent")

except exception as e:
print(e)
speak("sorry sir, i am not able to send the email")

# to close application
elif "close notepad" in self.query:
speak("okay sir,closing notepad")
os.system("taskkill /f/im notepad.exe")

elif "set alarm" in self.query:
nn = int(datetime.datetime.now().hour)
if nn == 11:
music_dir = "Libraries\\Music"
songs = os.listdir(music_dir)
os.startfile(os.path.join(music_dir, songs[0]))

elif "joke" in self.query:
joke = pyjokes.get_joke()
speak(joke)

elif "shutdown the system" in self.query:
os.system("shutdown /s /t 5")

elif "restart the system" in self.query:
os.system("shutdown /r /t 5")

elif "sleep the system" in self.query:
os.system("rundll32.exe powrprof.dll,SetSuspendState 0,1,0")

elif "thank you" in self.query:
speak("thankyou sir,have a good day")
sys.exit()

speak("sir,do you have any other work")



#if __name__ == "__main__" :
# TaskExecution()

startExecution = Mainthread()

class Main(QMainWindow):
def __init__(self):
super().__init__()
self.ui = Ui_jarvisUi()
self.ui.setupUi(self)
self.ui.pushButton.clicked.connect(self.startTask)
self.ui.pushButton_2.clicked.connect(self.close)

def startTask(self):
#self.ui.movie = QtGui.QMovie("Black_Template.jpg")
#self.ui.label.setMovie(self.ui.movie)
#self.ui.movie.start()
self.ui.movie = QtGui.QMovie("Iron_Template_1.gif")
self.ui.label_2.setMovie(self.ui.movie)
self.ui.movie.start()
self.ui.movie = QtGui.QMovie("jarvis_jj.gif")
self.ui.label_3.setMovie(self.ui.movie)
self.ui.movie.start()
self.ui.movie = QtGui.QMovie("initial.gif")
self.ui.label_4.setMovie(self.ui.movie)
self.ui.movie.start()
self.ui.movie = QtGui.QMovie("Health_Template.gif")
self.ui.label_5.setMovie(self.ui.movie)
self.ui.movie.start()
self.ui.movie = QtGui.QMovie("B.G_Template_1.gif")
self.ui.label_6.setMovie(self.ui.movie)
self.ui.movie.start()
timer = QTimer(self)
timer.timeout.connect(self.showTime)
timer.start(1000)
startExecution.start()

def showTime(self):
current_time = QTime.currentTime()
current_date = QDate.currentDate()
label_time = current_time.toString('hh:mm:ss')
label_date = current_date.toString(Qt.ISODate)
self.ui.textBrowser.setText(label_date)
self.ui.textBrowser_2.setText(label_time)



app = QApplication(sys.argv)
jarvis = Main()
jarvis.show()
exit(app.exec_())





Binary file added OTHERS/Jarvis/jarvis.zip
Binary file not shown.
102 changes: 102 additions & 0 deletions OTHERS/Jarvis/jarvisUi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'jarvisUi.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets


class Ui_jarvisUi(object):
def setupUi(self, jarvisUi):
jarvisUi.setObjectName("jarvisUi")
jarvisUi.resize(997, 533)
self.centralwidget = QtWidgets.QWidget(jarvisUi)
self.centralwidget.setObjectName("centralwidget")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(-170, -10, 1211, 541))
self.label.setText("")
self.label.setPixmap(QtGui.QPixmap("Black_Template.jpg"))
self.label.setScaledContents(True)
self.label.setObjectName("label")
self.label_2 = QtWidgets.QLabel(self.centralwidget)
self.label_2.setGeometry(QtCore.QRect(630, 10, 371, 281))
self.label_2.setText("")
self.label_2.setPixmap(QtGui.QPixmap("Iron_Template_1.gif"))
self.label_2.setScaledContents(True)
self.label_2.setObjectName("label_2")
self.label_3 = QtWidgets.QLabel(self.centralwidget)
self.label_3.setGeometry(QtCore.QRect(20, 180, 261, 181))
self.label_3.setText("")
self.label_3.setPixmap(QtGui.QPixmap("jarvis_jj.gif"))
self.label_3.setScaledContents(True)
self.label_3.setObjectName("label_3")
self.label_4 = QtWidgets.QLabel(self.centralwidget)
self.label_4.setGeometry(QtCore.QRect(16, 12, 521, 181))
self.label_4.setText("")
self.label_4.setPixmap(QtGui.QPixmap("initial.gif"))
self.label_4.setScaledContents(True)
self.label_4.setObjectName("label_4")
self.label_5 = QtWidgets.QLabel(self.centralwidget)
self.label_5.setGeometry(QtCore.QRect(20, 370, 281, 151))
self.label_5.setText("")
self.label_5.setPixmap(QtGui.QPixmap("Health_Template.gif"))
self.label_5.setScaledContents(True)
self.label_5.setObjectName("label_5")
self.label_6 = QtWidgets.QLabel(self.centralwidget)
self.label_6.setGeometry(QtCore.QRect(730, 320, 251, 181))
self.label_6.setText("")
self.label_6.setPixmap(QtGui.QPixmap("B.G_Template_1.gif"))
self.label_6.setScaledContents(True)
self.label_6.setObjectName("label_6")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(420, 360, 101, 51))
self.pushButton.setStyleSheet("color: rgb(0, 0, 255);\n"
"background-color: rgb(85, 255, 255);\n"
"font: 14pt \"MS UI Gothic\";")
self.pushButton.setObjectName("pushButton")
self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_2.setGeometry(QtCore.QRect(530, 360, 101, 51))
self.pushButton_2.setStyleSheet("color: rgb(0, 0, 255);\n"
"background-color: rgb(85, 255, 255);\n"
"font: 14pt \"MS UI Gothic\";\n"
"")
self.pushButton_2.setObjectName("pushButton_2")
self.textBrowser = QtWidgets.QTextBrowser(self.centralwidget)
self.textBrowser.setGeometry(QtCore.QRect(330, 470, 191, 51))
self.textBrowser.setStyleSheet("background-color: transparent;\n"
"border-radius:none;\n"
"color:white;\n"
"font-size:20px;")
self.textBrowser.setObjectName("textBrowser")
self.textBrowser_2 = QtWidgets.QTextBrowser(self.centralwidget)
self.textBrowser_2.setGeometry(QtCore.QRect(520, 470, 191, 51))
self.textBrowser_2.setStyleSheet("background-color: transparent;\n"
"border-radius:none;\n"
"color:white;\n"
"font-size:20px;")
self.textBrowser_2.setObjectName("textBrowser_2")
jarvisUi.setCentralWidget(self.centralwidget)

self.retranslateUi(jarvisUi)
QtCore.QMetaObject.connectSlotsByName(jarvisUi)

def retranslateUi(self, jarvisUi):
_translate = QtCore.QCoreApplication.translate
jarvisUi.setWindowTitle(_translate("jarvisUi", "MainWindow"))
self.pushButton.setText(_translate("jarvisUi", "START"))
self.pushButton_2.setText(_translate("jarvisUi", "EXIT"))


if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
jarvisUi = QtWidgets.QMainWindow()
ui = Ui_jarvisUi()
ui.setupUi(jarvisUi)
jarvisUi.show()
sys.exit(app.exec_())
Loading