Skip to content

Commit dad9201

Browse files
committed
first commit
0 parents  commit dad9201

File tree

6 files changed

+435
-0
lines changed

6 files changed

+435
-0
lines changed

Untitled-1.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
s= "subhadip saha sudi"
2+
ans = s.split(' ')
3+
ans1 = (((i.capitalize() for i in ans)))
4+
' '.join(ans1)
5+
print(ans1)

badass_jarvis.py

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
import os
2+
from time import strftime
3+
import pyttsx3
4+
import datetime
5+
import speech_recognition as sr
6+
import wikipedia
7+
import webbrowser
8+
import random
9+
import smtplib
10+
11+
engine = pyttsx3.init('sapi5')
12+
voices=engine.getProperty('voices')
13+
engine.setProperty('voices', voices[0].id)
14+
15+
email_dict={
16+
"me":"sahasubhadip54@gmail.com",
17+
"baba":"sasti.saha75@gmail.com",
18+
"didi":"sahasnehafkk@gmail.com"}
19+
20+
def speak(audio): #speak audio
21+
engine.say(audio)
22+
engine.runAndWait()
23+
24+
def wishMe(): #wishes me
25+
hour=int(datetime.datetime.now().hour)
26+
if hour>=0 and hour<=3:
27+
speak("Soja Lau rae, teri baandi nahi hae, hahahaha")
28+
29+
30+
elif hour>=4 and hour<12:
31+
speak("Uth gaya Lodu chand")
32+
elif hour>=12 and hour<17:
33+
speak("Saalae abhi sonae ka time hae mera, matt jagaya kar mekko bc!")
34+
elif hour>=17 and hour<19:
35+
speak("paar nae baith lodu")
36+
elif hour>=19 and hour<24:
37+
speak("lau rae soja bc")
38+
39+
if hour>=0 and hour<=4:
40+
pass
41+
else:
42+
speak("Hemlo domst, Mein hu Jarvis! Jarvis to chu tia hae ! mein hu badass jarvis! bol lau rae kya kar sakta hu tere liye, english mein bolna, developer chu tia hae, hindi voice nahi dala")
43+
44+
def takeCommand(): #takes microphone inout and returns output
45+
r=sr.Recognizer()
46+
with sr.Microphone() as source:
47+
print("Listening...")
48+
r.pause_threshold=1
49+
audio = r.listen(source)
50+
51+
try:
52+
print("Recognizing...")
53+
query = r.recognize_google(audio, language='en-in') #Using google for voice recognition
54+
print(f"User said: {query}\n") #User query will be printed
55+
except Exception as e:
56+
print("Say that again please...") #Say that again will be printed in case of improper voice
57+
return "None" #None string will be returned
58+
return query
59+
60+
def sendEmail(to, econtent): #sending email
61+
server = smtplib.SMTP('smtp.gmail.com', 587)
62+
server.ehlo()
63+
server.starttls()
64+
server.login('subhadipsudi@gmail.com', 'Sudi@1234')
65+
server.sendmail('subhadipsudi@gmail.com', to, econtent)
66+
server.close()
67+
68+
if __name__ == "__main__":
69+
wishMe()
70+
speak("Jaldi bol! kaal subha panvel nikalna hae")
71+
while True:
72+
query = takeCommand().lower()
73+
74+
if 'wikipedia' in query:
75+
speak('Dhunndh raaha hu')
76+
query = query.replace("according to wikipedia","")
77+
results=wikipedia.summary(query, sentences=2)
78+
speak("Accoring to Wikipedia")
79+
print(results)
80+
speak(results)
81+
82+
elif 'open youtube' in query:
83+
speak("Here We Go")
84+
webbrowser.open("youtube.com")
85+
elif 'youtube' in query and 'search' in query:
86+
speak("paehelae baataa raaha hu! porn videos nahi mil lengue")
87+
search_yt=takeCommand()
88+
search_yt=search_yt.replace(" ","+")
89+
speak("Here We Go")
90+
webbrowser.open(f"https://www.youtube.com/results?search_query={search_yt}")
91+
elif 'open google' in query:
92+
speak("Here We Go")
93+
webbrowser.open("google.com")
94+
elif 'google' in query and 'search' in query:
95+
speak("tere baaap ka naukar samajh ke rakha hae mujhe")
96+
search_go=takeCommand()
97+
search_go=search_go.replace(" ","+")
98+
speak("Here We Go")
99+
webbrowser.open(f"https://www.google.com/search?q={search_go}")
100+
elif 'open instagram' in query:
101+
speak("Here We Go")
102+
webbrowser.open("instagram.com")
103+
elif 'open facebook' in query:
104+
speak("Here We Go")
105+
webbrowser.open("facebook.com")
106+
elif 'open twitter' in query:
107+
speak("Here We Go")
108+
webbrowser.open("twitter.com")
109+
elif 'download youtube videos' in query:
110+
speak("Here We Go")
111+
webbrowser.open("en.onlinevideoconverter.pro")
112+
elif 'play music' in query:
113+
music_dir = 'C:\\Users\\sahas\\OneDrive\\Desktop\\Subhadip\\Media\\Fav one'
114+
songs = os.listdir(music_dir)
115+
a=len(songs)-1
116+
ran_num= random.randint(0,a)
117+
os.startfile(os.path.join(music_dir, songs[ran_num]))
118+
elif 'the time' in query:
119+
strTime = datetime.datetime.now().strftime("%H:%M:%S")
120+
speak(strTime)
121+
elif 'the date' in query:
122+
today=datetime.date.today()
123+
speak(today)
124+
elif 'open downloads' in query:
125+
downloadPath='C:\\Users\\sahas\\Downloads'
126+
os.startfile(downloadPath)
127+
elif 'my important documents' in query:
128+
downloadPath='F:\\Media'
129+
os.startfile(downloadPath)
130+
elif 'my media' in query:
131+
downloadPath='F:\\Docs'
132+
os.startfile(downloadPath)
133+
elif 'code' in query:
134+
ApplicationPath="C:\\Users\\sahas\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe"
135+
os.startfile(ApplicationPath)
136+
elif 'filmora' in query:
137+
ApplicationPath="C:\\Program Files\\Wondershare\\Filmora9\\Wondershare Filmora9.exe"
138+
os.startfile(ApplicationPath)
139+
elif 'chrome' in query:
140+
ApplicationPath="C:\\Program Files\\Google\Chrome\\Application\\chrome.exe"
141+
os.startfile(ApplicationPath)
142+
elif 'email' in query:
143+
try:
144+
if 'me' in query:
145+
to = email_dict.get("me")
146+
elif 'baba' in query:
147+
to = email_dict.get("baba")
148+
elif 'didi' in query:
149+
to = email_dict.get("didi")
150+
else:
151+
to = input("Enter New Email: ")
152+
153+
speak("kya likhu lau rae")
154+
econtent=takeCommand()
155+
sendEmail(to, econtent)
156+
speak("Email has been sent!")
157+
except Exception as e:
158+
print("Sorry Sir, I can't send the email")
159+
speak("lagtaa hae server ki gaand faati paari hae")
160+
elif query == 'jarvis':
161+
speak("Gaand mae daal liyo Jarvis")
162+
elif 'joke' in query:
163+
speak("teri zin-dagui-saae baari or kya joke hae! hahahahha! destroyed waala meme daal dena please")
164+
elif 'todo'in query or 'to do' in query:
165+
if 'add' in query or 'create' in query:
166+
with open('todo.txt','a') as f:
167+
todo_w=takeCommand()
168+
f.write(f"{todo_w}\n")
169+
speak("kaam ho gya")
170+
elif 'read' in query or 'tell' in query:
171+
with open('todo.txt','r') as f:
172+
todo_r=f.read()
173+
if todo_r =="":
174+
todo_r="No Pendning Tasks Sir"
175+
speak(todo_r)
176+
elif 'erase' in query or 'remove all' in query or 'clear' in query:
177+
with open("todo.txt","w") as f:
178+
f.write("")
179+
speak("kaam ho gya lau rae !")
180+
elif 'jarvis quit' in query or 'exit' in query or 'close' in query:
181+
speak("nikal lau rae, paeheli fursat mae nikal")
182+
exit()

jarvis.py

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
import os
2+
from time import strftime
3+
import pyttsx3
4+
import datetime
5+
import speech_recognition as sr
6+
import wikipedia
7+
import webbrowser
8+
import random
9+
import smtplib
10+
11+
12+
13+
engine = pyttsx3.init('sapi5')
14+
voices=engine.getProperty('voices')
15+
engine.setProperty('voices', voices[0].id)
16+
17+
email_dict={
18+
"me":"sahasubhadip54@gmail.com",
19+
"baba":"sasti.saha75@gmail.com",
20+
"didi":"sahasnehafkk@gmail.com"}
21+
22+
23+
24+
list_of_jokes = ["The three most well known languages in India are English, Hindi, and... JavaScript","Interviewer... Where were you born?Me in India... Interviewer:.. oh, which part?... Me: What ‘which part’ ..? Whole body was born in India","how many Indians does it take to fix a lightbulb?Two. One to do the task and other to explain how lightbulbs were actually invented in ancient India","What do you call bread from India? It's Naan of your business","Britain: Drive on the left side... Europe and America: Drive on the right side...India: lol what's a 'traffic law'?"]
25+
jokes = len(list_of_jokes)-1
26+
ran_joke=random.randint(0,jokes)
27+
28+
29+
30+
def speak(audio): #speak audio
31+
engine.say(audio)
32+
engine.runAndWait()
33+
34+
def wishMe(): #wishes me
35+
hour=int(datetime.datetime.now().hour)
36+
if hour>=0 and hour<=3:
37+
speak("It's Late Night Sir!, You should sleep right now")
38+
39+
40+
elif hour>=4 and hour<12:
41+
speak("Good Moring Master!")
42+
elif hour>=12 and hour<17:
43+
speak("Good Afternoon Sir !")
44+
elif hour>=17 and hour<19:
45+
speak("Good Evening !")
46+
elif hour>=19 and hour<24:
47+
speak("Good Night Sir!")
48+
49+
if hour>=0 and hour<=4:
50+
pass
51+
else:
52+
speak("I am Your Personal assistant, Jarvis! version 1.2! With the power of 8 gigabytes of ram, along with GPU and SSD")
53+
54+
def takeCommand(): #takes microphone inout and returns output
55+
r=sr.Recognizer()
56+
with sr.Microphone() as source:
57+
print("Listening...")
58+
r.pause_threshold=1
59+
audio = r.listen(source)
60+
61+
try:
62+
print("Recognizing...")
63+
query = r.recognize_google(audio, language='en-in') #Using google for voice recognition
64+
print(f"User said: {query}\n") #User query will be printed
65+
except Exception as e:
66+
print("Say that again please...") #Say that again will be printed in case of improper voice
67+
return "None" #None string will be returned
68+
return query
69+
70+
def sendEmail(to, econtent): #sending email
71+
server = smtplib.SMTP('smtp.gmail.com', 587)
72+
server.ehlo()
73+
server.starttls()
74+
server.login('subhadipsudi@gmail.com', 'Sudi@1234')
75+
server.sendmail('subhadipsudi@gmail.com', to, econtent)
76+
server.close()
77+
78+
if __name__ == "__main__":
79+
wishMe()
80+
speak("How May I Help You Sir ?")
81+
while True:
82+
query = takeCommand().lower()
83+
84+
if 'wikipedia' in query:
85+
speak('Searching in Wikipedia')
86+
query = query.replace("according to wikipedia","")
87+
results=wikipedia.summary(query, sentences=2)
88+
speak("Accoring to Wikipedia")
89+
print(results)
90+
speak(results)
91+
92+
elif 'open youtube' in query:
93+
speak("Here We Go")
94+
webbrowser.open("youtube.com")
95+
elif 'youtube' in query and 'search' in query:
96+
speak("What Should I Search Sir ?")
97+
search_yt=takeCommand()
98+
search_yt=search_yt.replace(" ","+")
99+
speak("Here We Go")
100+
webbrowser.open(f"https://www.youtube.com/results?search_query={search_yt}")
101+
elif 'open google' in query:
102+
speak("Here We Go")
103+
webbrowser.open("google.com")
104+
elif 'google' in query and 'search' in query:
105+
speak("What Should I Search Sir ?")
106+
search_go=takeCommand()
107+
search_go=search_go.replace(" ","+")
108+
speak("Here We Go")
109+
webbrowser.open(f"https://www.google.com/search?q={search_go}")
110+
elif 'open instagram' in query:
111+
speak("Here We Go")
112+
webbrowser.open("instagram.com")
113+
elif 'open facebook' in query:
114+
speak("Here We Go")
115+
webbrowser.open("facebook.com")
116+
elif 'open twitter' in query:
117+
speak("Here We Go")
118+
webbrowser.open("twitter.com")
119+
elif 'download youtube videos' in query:
120+
speak("Here We Go")
121+
webbrowser.open("en.onlinevideoconverter.pro")
122+
elif 'play music' in query:
123+
music_dir = 'C:\\Users\\sahas\\OneDrive\\Desktop\\Subhadip\\Media\\Fav one'
124+
songs = os.listdir(music_dir)
125+
a=len(songs)-1
126+
ran_num= random.randint(0,a)
127+
os.startfile(os.path.join(music_dir, songs[ran_num]))
128+
elif 'the time' in query:
129+
strTime = datetime.datetime.now().strftime("%H:%M:%S")
130+
speak(strTime)
131+
elif 'the date' in query:
132+
today=datetime.date.today()
133+
speak(today)
134+
elif 'open downloads' in query:
135+
downloadPath='C:\\Users\\sahas\\Downloads'
136+
os.startfile(downloadPath)
137+
elif 'my important documents' in query:
138+
downloadPath='F:\\Media'
139+
os.startfile(downloadPath)
140+
elif 'my media' in query:
141+
downloadPath='F:\\Docs'
142+
os.startfile(downloadPath)
143+
elif 'code' in query:
144+
ApplicationPath="C:\\Users\\sahas\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe"
145+
os.startfile(ApplicationPath)
146+
elif 'filmora' in query:
147+
ApplicationPath="C:\\Program Files\\Wondershare\\Filmora9\\Wondershare Filmora9.exe"
148+
os.startfile(ApplicationPath)
149+
elif 'chrome' in query:
150+
ApplicationPath="C:\\Program Files\\Google\Chrome\\Application\\chrome.exe"
151+
os.startfile(ApplicationPath)
152+
elif 'email' in query:
153+
try:
154+
if 'me' in query:
155+
to = email_dict.get("me")
156+
elif 'baba' in query:
157+
to = email_dict.get("baba")
158+
elif 'didi' in query:
159+
to = email_dict.get("didi")
160+
else:
161+
to = input("Enter New Email: ")
162+
163+
speak("What should I say ?")
164+
econtent=takeCommand()
165+
sendEmail(to, econtent)
166+
speak("Email has been sent!")
167+
except Exception as e:
168+
print("Sorry Sir, I can't send the email")
169+
speak("Sorry Sir, I can't send the email")
170+
elif query == 'jarvis':
171+
speak("At Your Service Sir, How can I help you")
172+
elif 'joke' in query:
173+
speak(list_of_jokes[ran_joke])
174+
elif 'todo'in query or 'to do' in query:
175+
if 'add' in query or 'create' in query:
176+
with open('todo.txt','a') as f:
177+
todo_w=takeCommand()
178+
f.write(f"{todo_w}\n")
179+
speak("To Do is updated successfully !")
180+
elif 'read' in query or 'tell' in query:
181+
with open('todo.txt','r') as f:
182+
todo_r=f.read()
183+
if todo_r =="":
184+
todo_r="No Pendning Tasks Sir"
185+
speak(todo_r)
186+
elif 'erase' in query or 'remove all' in query or 'clear' in query:
187+
with open("todo.txt","w") as f:
188+
f.write("")
189+
speak("All Tasks has been cleared, Sir !")
190+
elif 'jarvis quit' in query or 'exit' in query or 'close' in query:
191+
speak("Thanks you for using Jarvis Sir")
192+
exit()

0 commit comments

Comments
 (0)