Skip to main content

Jarvis in Python

  JARVIS IN PYTHON    

        Python installing steps

1.  Download visual studio code

2.  Install python.org

3.  Verify python was installed on window

     Python startup steps 

1.  One visual studio code

2.  Welcome window

3.  Open folder

4.  New folder

5.  Select folder

6.  Create new file

7.  Python 3.7 A 32 bit

8.  Right click

9.  Window power shell

10.Write python

11.Write exit()

12.Install pip pandas

13.Print(“Hello world \n”)

14.Go to extention

15.Search code runner

16.Install it 

      Opening steps to create Jarvis :

1.  Desktop

2.  New folder

3.  Name : Jarvis

4.  Click shift

5.  Open power shell windows here

6.  Type – code

7.  Open editors

8.  Jarvis

9.  Name : jarvis.py 

      What is voice assistant ?

  A voice assistant is a speech recognition process of audio in to test. Voice assistant like Alexa, siri, etc. Python provides an API called speech recognition to convert audio to text for further process.

      What we are building ?

    Build Jarvis using python it's a voice assistant. It's a artificial intelligence techniques language processing speech recognition written in python. For assistants like Jarvis to be able to control the systems in phone or your pc. Voice and speech recognition we think that text will be more important for the communication. But still we realise voice also play a very important role too. The useful aspect of voice is that it's very fast. No need to take phone, open any type of app or start typing; you just speak.



* Coding for Jarvis in python :

import pyttsx3
import speech_recognition as Sr
import datetime
import wikipedia
import os
import smtplib
engine = pyttsx3.init('sapi 5')
voice = engine.getProperty('voices')
print(voices[0].id)
engine.SetProperty('voice',voices[0]id)

def speak(audio)
     engine.say(audio)
     engine.runAndwait

def wishMe():
     hour = int(datetime.datetime.now().hour)
     if hour>= 0 and hour<12:
        Speak("Good Morning!")
     elif hour>= 12 and hour<18:
        Speak("Good Afternoon!")
     else:
        Speak("Good Evening!")
        Speak ("I am Jarvis Sir. Please tell me How may I
                    Help you")
def takeCommand():
#take microphone input from the user and returns string             output.
     r = Sr.Recognizer()
     with Sr.Microphone() as source:
        print("Listening....")
        r.pause_threshold = 1
        audio = r.listen(source)
       
     try:
        print("Recognising...")
        query = r.recognizer_google(audio, Language =
                                         'en-in')
        print(if"user said : {query}\n")

     except Exception as e :
        print(e)
        print("Say that again please....")
        return "None"
     return query
def sendEmail(to,content) :
     server = smtplib.SMTP('smtp.gmail.com',587)
     server.ehlo()
     server.startis()
     server.login('email id','password')
     server.sendmail('email id',to,content)
     server.close()
if_name_=="_main_":
     wishMe()
     While True :
        query = takeCommand(). lower()

#logic for executing tasks based on query

     if 'wikipedia' in query :
        speak('Searching Wikipedia....')
        query = query.replace("Wikipedia"," ")
        results = wikipedia.summary(query, sentence = 2)
        speak ("According to Wikipedia")
        print (result)
        speak(result)
     elif 'open youtube' in query:
        webbrowser.open("youtube.com")
     elif 'open google' in query:
        webbrowser.open("google.com")
     elif 'playmusic' in query:
        music_dir = "D:\\Non Critical\\Songs\\Favorite                
                                          Songs 2"
        song = is.list dir(music_dir)
        print(songs)
        os.startfile(os.path.join(music_dir,songs[0])) 
       
     elif 'the time' in query:
        StrTime = datetime.datetime.now().StrTime("%H:
                             %M: %S")
                            
        speak(If "Sir, the time is {StrTime}")
       
     elif 'email to Aleena' in query:
        try:
           speak("What should I Say?")
           content = takeCommand()
           to = "Aleenayouremail@gmail.com"
           sendEmail(to, content)
           speack("Email has been send!")
          
     except Exception as e:
           print(e)
           speak("Sorry my friend Aleena. Iam not able
                          to send this email")                         
    
       
                            
     
   
    


Comments

Popular posts from this blog

What is Operator Overloading?

  OPERATOR OVERLOADING :             The mechanism of giving such special meaning to an operator is known as operator overloading.             Operator overloading provides flexible options for the creation of new definitions for most of the c++ operators accept the following:             1] class member access operator(.)             2] scope resolution operator(::)             3] size of operator(size of)             4] condition operator or ternary operator(?:)   Operator overloading is used to redefine the operators available in C++. It is used to perform operation on the user-defined data type. Example for operator overloading : Overload an operator '+' in a class like string to concatenate two strings using +. Advantages of operator overloading : Enables programmers to use notation closer to target domin. Provides similar syntactic support to user-defined types. It makes the program easier to understand. Rules for operator overloading : Cannot overload overloa