how to make jarvis in python

Solutions on MaxInterview for how to make jarvis in python by the best coders in the world

showing results for - "how to make jarvis in python"
Valeria
07 Sep 2016
1import pyttsx3 
2import speech_recognition as sr 
3import datetime
4import wikipedia 
5import webbrowser
6import os
7import smtplib
8
9engine = pyttsx3.init('sapi5')
10voices = engine.getProperty('voices')
11# print(voices[1].id)
12engine.setProperty('voice', voices[1].id)
13
14
15def speak(audio):
16    engine.say(audio)
17    engine.runAndWait()
18
19
20def wishMe():
21    hour = int(datetime.datetime.now().hour)
22    if hour>=0 and hour<12:
23        speak("Good Morning!")
24
25    elif hour>=12 and hour<18:
26        speak("Good Afternoon!")   
27
28    else:
29        speak("Good Evening!")  
30
31    speak("Hello Neel ,how may I help you")       
32
33def takeCommand():
34    #It takes microphone input from the user and returns string output
35
36    r = sr.Recognizer()
37    with sr.Microphone() as source:
38        print("Listening...")
39        r.pause_threshold = 2
40        audio = r.listen(source)
41
42    try:
43        print("Recognizing...")    
44        query = r.recognize_google(audio, language='en-in')
45        print(f"User said: {query}\n")
46
47    except Exception as e:
48        # print(e)    
49        print("Say that again please...")  
50        return "None"
51    return query
52
53def sendEmail(to, content):
54    server = smtplib.SMTP('smtp.gmail.com', 587)
55    server.ehlo()
56    server.starttls()
57    server.login('Your Email', 'Your Password')
58    server.sendmail('Your Email', to, content)
59    server.close()
60
61if __name__ == "__main__":
62    wishMe()
63    while True:
64    # if 1:
65        query = takeCommand().lower()
66
67        # Logic for executing tasks based on query
68        if 'wikipedia' in query:
69            speak('Searching Wikipedia...')
70            query = query.replace("wikipedia", "")
71            results = wikipedia.summary(query, sentences=10)
72            speak("According to Wikipedia")
73            print(results)
74            speak(results)
75
76        elif 'open youtube' in query:
77            webbrowser.open("youtube.com")
78
79        elif 'open stackoverflow' in query:
80            webbrowser.open("stackoverflow.com")  
81
82        elif 'open python' in query:
83            webbrowser.open("coursera.org")   
84        elif 'open github' in query:
85            webbrowser.open("github.com")   
86
87        elif 'open mail' in query:
88            webbrowser.open("mail.google.com")   
89      
90
91
92
93        elif 'play music' in query:
94            music_dir = 'C:\\Users\\Admin\\Music\\my.mp3'
95            songs = os.listdir(music_dir)
96            print(songs)    
97            os.startfile(os.path.join(music_dir, songs[0]))
98
99        elif 'the time' in query:
100            strTime = datetime.datetime.now().strftime("%H:%M:%S")    
101            speak(f"Sir, the time is {strTime}")
102
103        elif 'open code' in query:
104            codePath = "E:\\Microsoft VS Code\\Code.exe"
105            os.startfile(codePath)
106
107        elif 'open google' in query:
108            go = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
109            os.startfile(go)
110
111        elif 'email to me' in query:
112            try:
113                speak("What should I say?")
114                content = takeCommand()
115                to = "you@youremail.com"    
116                sendEmail(to, content)
117                speak("Email has been sent!")
118            except Exception as e:
119                print(e)
120                speak("Sorry Neelansh, I couldn't send the email")
queries leading to this page
how to make a personal assistant like jarvis in pythonjarvis python project code examplepyttsx3 jarvis voice downloadhow to make a jarvis in pythonhow to make jarvis with gttsmaking jarvis in pythonhow to make jarvis voice in pythobhow to make a jarvis ai in pythongtts using python and jarvisjarvis code pythonjarvis using pythoncreating jarvis in pythonmake a trasnlator in jarvis pythonhow to download jarvis in python 3 6jarvis module in pythonopen jarvis et pythoncode for jarvis in pythonhow to implement jarvis in pythonjarvis python scriptpython jarvis source codewhat can jarvis python do 3fbuild jarvis using pythonai jarvis pythonhow to make a jarvis with pythonhow to build jarvis in pythonjarvis python tutorialmake adavance jarvis in pythonmake jarvis with python for beginnersmake jarvis using pythonjarvis python librarypython jarvis modulehow to add graphics in python program jarvishow to make definitions with python in jarviswhere i am jarvis python codehow to end python program jarviscoding jarvis in pythonjarvis project in python with codejarvis pythonmaking jarvis with pythonjarvis through pythoncomplete code of jarvis in pythonjarvis iron man pythonmaking jarvis using pythonmake jarvis with pythonpython how to make your own jarvis aihow to do google 2fyoutube search with python jarvis aijarvis full code in pythonjarvis voice in ai pythonhow to create a jarvis in pythonjarvis not taing commands in pythonsource code for jarvis in pythonhow to install jarvis in pythonjarvis assistant programpython jarvis codejarvis et pythoncreate jarvis using pythonjarvis in pythonmake jarvis in pythonjarvis in python with googlehow to make jarvis using pythonjarvis on pythonjarvis program in pythonhow to create jarvis with pythonjarvis code in python mono how to turn of your oc with jarvis ai pythonjarvis code in python downloadjarvis python codepython jarvisaihow to make python speak jarvis google resultspython jarvispython how to make a jarvis aioffline speech recognition for jarvis in pythonhow to make location in jarvis with pythonpython jarvis programhow to install javis pythonjarvis python source codehow to make jarvis in pythonjarvis code in pythonhow to create jarvis in pythonpython how to make a jarvisbest modules for jarvis in pythoncan jarvis be made in pythonhow to make a math with python in jarvisjarvis by pythonjarvis voice engine for pythonjarvis python projectjarvis with pythonjarvis pyton codecreate jarvis with pythonjarvis voice pythonjarvis thriugh pythonadd jarvis in pythonmake jarvis pythonwhat features should jarvis have in pythonpython code for jarvisjarvis in python examplejarvis in python source codehow to make jarvis in python