Jarvis Desktop Assistant With GUI Using Python



 Introduction

Jarvis who was the private voice assistant of Iron man i.e. Tony Stark. It wont to control all machines and robots of Tony Stark, Iron man Suit. this is often on Voice Command, one such Voice Assistant which is male I even have created it named Jarvis and It works on my Command, I even have been performing on this for an extended time, since I saw the Iron-man movie, since then i used to be collecting ideas and knowledge to form this,it was only for my computer.

In this post i will be able to tell you ways to form your own Jarvis Desktop Assistant with GUI.

I used Python programing language to create it.

So let's examine the code of this desktop assistant

Also read :  How to Create Flappy Bird Game In Python | Free Tutorial With Souce Code

Also read :  Bluehost Review 2020 | Is Bluehost is worthy for price [truth revealed] - best review

Module we need for this Desktop Assistant

  • Espeak - if you are in linux based operating system. In windows you did not have to install this espeak     
  • Pyttsx3
  • Tkinter 
  •  Os
  •  PILRandom
  • Time
  • Webbrowser
  • Subprocess

Command to install Modules

  • Espeak - In Linux - sudo apt install espeak
  •               In windows - sapi5 is preinstalled
  • Pyttsx3 - pip install pyttsx3
  • Tkinter - pip install tkinter
  • Os - preinstall
  • PIL - pip install PIL
  • Random - preinstall
  • Time - preinstall
  • Webbrowser - preinstall
  • Subprocess - preinstall

For installing python programming language simple to have to click to this link given below -

 Download Python from this link



Also read : How to create Snake Game Using Python | Free Python Project with source code

Code For Jarvis Desktop Assistant

import random         
import tkinter          # pip install tkinter
from tkinter import *
import datetime    
import pyttsx3          # pip install pyttsx3
import os
import time
import subprocess
import webbrowser
from tkinter import _tkinter
from PIL import ImageTk,Image     # pip install PIL
engine = pyttsx3.init()
# in windows
# engine = pyttsx3.init('sapi5')
window = Tk()
window.configure(bg = "black")  
SET_WIDTH = 800
SET_HEIGHT = 700
global ques
ques = Entry(window,width=40,bg="black",fg="white",font = ('arial',18,'bold'))  
ques.pack(padx = 10,pady = 20)
def speak(audio):
    engine.say(audio)
    engine.runAndWait()
def wish():
    hour = int(datetime.datetime.now().hour)
    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")
def command():
    if 'open desktop' in ques.get():
       
        speak("ok sir do it ")
        # d = "C:\Users\Public\Desktop"
        os.startfile(d)
        # or
        # os.system(d)
       
    elif 'open file' in ques.get():
       
        speak("which file sir ")
        d = Toplevel()
        Toplevel.configure(bg="black")
        e = Entry(d,bg = "black", fg = "white" ,width = 20)
        e.pack()
        def open_file():
            os.system(e.get())
            speak("ok sir i will open "+e.get())
        s = Button(d,bg = "black",font = ('arial',18,'bold'),fg  = "white",width = 10,activeforeground = "grey",activebackground = "black",text = "open it",command=open_file).pack()
    elif 'shutdown' in ques.get():
        os.system("shutdown now -h")
        speak("ok sir i shutdown the computer")
    elif 'open stackoverflow' in ques.get():
        speak("ok sir i will open the stck over flow website")
        webbrowser.open("https://wwww.stackoverflow.com")
    elif 'open website' in ques.get():
        speak("which website sir ")
        d = Toplevel()
        e = Entry(d,bg = "black", fg = "white" ,font = ('arial',18,'bold'),width = 20)
        e.pack()
        def open_web():
            webbrowser.open("https://"+e.get()+".com")
            speak("ok sir i will open "+e.get())
        s = Button(d,bg = "black",fg  = "white",width = 10,activeforeground = "grey",activebackground = "black",text = "open it",command=open_web).pack()
    elif 'open google' in ques.get():
        speak("ok sir i will open google.com")
        webbrowser.open("https://wwww.google.com")
    elif 'open youtube' in ques.get():
        speak("ok sir i will opwn youtube dot com")
        webbrowser.open("https://wwww.youtube.com")
    elif 'copy code' in ques.get():
        speak("of which file sir ")
        d = Toplevel()
        e = Entry(d,bg = "black",font = ('arial',18,'bold'), fg = "white" ,width = 20)
        e.pack()
        def open_code():
            file = open(e.get(),"r+")
            re = file.read()
            speak(re)
        s = Button(d,bg = "black",fg  = "white",width = 10,activeforeground = "grey",activebackground = "black",text = "open it",command=open_code).pack()
       
    elif 'exit' in ques.get():
        exit()
        speak("good bye sir have a good day")
    elif 'quite' in ques.get():
        speak("good bye sir have a good day")
        exit()
    else :
        speak("sorry sir i can not do this")
   
def you():
    speak("ok sir open the youtube.com")
    webbrowser.open("https://www.youtube.com")
def win():
    speak("ok sir i open it")
    webbrowser.open("https://techflayer.blogspot.com")
   
def main():
    # screen
    bgImg = Image.open("/home/abhishek/Desktop/Assistants/back.png")
    window.title("J.A.R.V.I.S")
    canvas = tkinter.Canvas(window,width = SET_WIDTH,height = SET_HEIGHT)
  
   
    # image=ImageTk.PhotoImage(Image.open("back.png")
    image=ImageTk.PhotoImage(bgImg)
    canvas.create_image(0,0,anchor=NW,image=image)
    # entry
    btn = Button(text = "Open Techflayer" ,bg = "black" ,fg="white",width=20,activeforeground = "grey",activebackground = "black",command = win)
    btn.pack(padx = 0,pady= 0)
    btn = Button(text = " Open Youtube" ,bg = "black",fg = "white" ,width = 20,activeforeground  = "grey" ,activebackground = "black",command =you)
    btn.pack(side = TOP)
    btn = Button(bg = "black" ,fg = "white",width=20,activeforeground = "grey",activebackground = "black",text = "command",command=command).pack(side = BOTTOM,pady = 1 , padx = 3)
    canvas.configure(bg="black")
   
   
    shape = canvas.create_oval(10,10,60,60,fill = "blue")
    xspeed = random.randrange(1,8)
    yspeed = random.randrange(1, 8)
    shape2 = canvas.create_oval(10,10,60,60,fill = "blue")
    xspeed2 = random.randrange(1,9)
    yspeed2 = random.randrange(1,9)
    canvas.pack()
   
    while True:
        canvas.move(shape,xspeed,yspeed)
        pos = canvas.coords(shape)
        if pos[3]>= 700 or pos[1] <=0:
            yspeed = -yspeed
        if pos[2] >= 800 or pos[0] <=0:
            xspeed= -xspeed
        canvas.move(shape2,xspeed2,yspeed2)
        pos = canvas.coords(shape2)
        if pos[3]>= 700 or pos[1] <=0:
            yspeed2 = -yspeed2
        if pos[2] >= 800 or pos[0] <=0:
            xspeed2= -xspeed2                               
        window.update()
        time.sleep(0.01)
   
def ball():
    canvas = Canvas()
if __name__ == "__main__":
    wish()
    main()
window.mainloop()
download the code from this link

Conclusion - 

Create desktop assistant i.e. Jarvis and you'll submit it as your the school project otherwise you can use it on your computer too. Friends, if you need to get the present day updates of our website, then please join our Techflayer, this can maintain you from getting the state-of-the-art updates about our upcoming.

Also read : How to Make Snake Game In JavaScript | Free tutorial With Source Code

Also read : How to Create WordPress Website with Bluehost | Step by Step Tutorial for Starters in 2020

Also read : How to make WordPress website with BlueHost in 10 minutes | best hosting BlueHost
Also read : Straightforward Forex Tricks You Can Use Today
Also read : How Social Media Can Impact Your SEO In 2020 | Information about SEO

Hope you like this project. Support us by donating B.A.T (Brave Rewards).

new posts, and recollect to follow us you'll locate the observe button on sidebar click and observe us , take into account to remark your thoughts , buddies will see you once more for this day, bye bye to you till then. Have a pleasing day

Comments

  1. Please share this article to friends to help them in their project and to improving your coding skills and subscribe our blog for more amazing projects and coding tutorials

    ReplyDelete
  2. Hi sir, I have code follow your direction but on the line 120 it has error like FileNotFoundError: [Errno 2] No such file or directory: 'back2.png'. Can you help me ? Thank you sir

    ReplyDelete
    Replies
    1. back2.png is the name of the image which is in the download link, you can name any image as back2.png and put it in the same folder then run the code

      Delete

Post a Comment