Example #1
0
                client = Client(account_sid, auth_token)

                talk("What should i send")
                message = client.messages.create(body=rec_audio(),
                                                 from_="from No.",
                                                 to="to No.")

                print(message.sid)
                speak = speak + "Message sent successfully"

            elif "calculate" in text:
                app_id = "Wolfram Alpha ID"
                client = wolframalpha.Client(app_id)
                ind = text.lower().split().index("calculate")
                text = text.split()[ind + 1:]
                res = client.query(" ".join(text))
                answer = next(res.results).text
                speak = speak + "The answer is " + answer

            elif "what is" in text or "who is" in text:
                app_id = "Wolfram Alpha ID"
                client = wolframalpha.Client(app_id)
                ind = text.lower().split().index("is")
                text = text.split()[ind + 1:]
                res = client.query(" ".join(text))
                answer = next(res.results).text
                speak = speak + answer

            elif "don't listen" in text or "stop listening" in text or "do not listen" in text:
                talk("for how many seconds do you want me to sleep")
                a = int(rec_audio())
Example #2
0
            message = client.messages.create(from_='whatsapp:+14155238886',
                                             body=body,
                                             to=to)
            speak('Sent Message')
        elif 'wikipedia' in query:
            print('What should I search in WikiPedia?')
            speak('What should I search in WikiPedia?')
            ans = takeCommand()
            try:
                results = wikipedia.summary(ans, sentences=2)
                speak("According to WikiPedia...")
                print(results)
                speak(results)
            except Exception as e:
                try:
                    res = client.query(ans)
                    speak('According to wolframalpha,')
                    print((next(res.results).text))
                    speak(next(res.results).text)
                except Exception as e:
                    speak('Sorry Sir there are no results found for')
                    speak(ans)
# Change my Name ----------####################################################################
        elif 'change my name' in query:
            speak('Ok Sir what should I call you?')
            myname = takeCommand()
            myname = myname.replace(" ", "")
            speak(myname)
            speak('Is this correct Sir?')
            ans = takeCommand()
            if 'no' in ans:
Example #3
0
            speak("A warm" +query) 
            speak("How are you Mister") 
            speak(assname) 
  
        # most asked question from google Assistant 
        elif "will you be my gf" in query or "will you be my bf" in query:    
            speak("I'm not sure about, may be you should give me some time") 
  
        elif "how are you" in query: 
            speak("I'm fine, glad you me that") 
  
        elif "i love you" in query: 
            speak("It's hard to understand") 
  
        elif "what is" in query or "who is" in query: 
              
            # Use the same API key  
            # that we have generated earlier 
            client = wolframalpha.Client("API_ID") 
            res = client.query(query) 
              
            try: 
                print (next(res.results).text) 
                speak (next(res.results).text) 
            except StopIteration: 
                print ("No results") 
  
        # elif "" in query: 
            # Command go here 
            # For adding more commands
Example #4
0
    def run_Bella(self):
        wishMe()
        while True:
            # if 1:

            self.query = self.takeCommand().lower()

            # Logic for executing tasks based on self.query
            if 'wikipedia' in self.query:
                speak('Searching Wikipedia...')
                self.query = self.query.replace("wikipedia", "")
                results = wikipedia.summary(self.query, sentences=2)
                speak("According to Wikipedia")
                print(results)
                speak(results)

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

            elif 'open google' in self.query:
                webbrowser.open("google.com")

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

            elif 'play' in self.query:
                song = self.query.replace('play', '')
                speak('playing ' + song)
                pywhatkit.playonyt(song)

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

            elif 'the time' in self.query:
                strTime = datetime.datetime.now().strftime("%H:%M:%S")
                speak(f"Sir, the time is {strTime}")

            elif 'open code' in self.query:
                codePath = " C:/Users/dell/AppData/Local/Programs/Python/Python39/python.exe"
                os.startfile(codePath)

            elif 'open facebook' in self.query:
                webbrowser.open("https://www.facebook.com")
                speak("opening facebook")

            elif 'open instagram' in self.query:
                webbrowser.open("https://www.instagram.com")
                speak("opening instagram")

            elif 'open yahoo' in self.query:
                webbrowser.open("https://www.yahoo.com")
                speak("opening yahoo")

            elif 'open gmail' in self.query:
                webbrowser.open("https://mail.google.com")
                speak("opening google mail")

            elif 'open snapdeal' in self.query:
                webbrowser.open("https://www.snapdeal.com")
                speak("opening snapdeal")

            elif 'open amazon' in self.query or 'shop online' in self.query:
                webbrowser.open("https://www.amazon.com")
                speak("opening amazon")

            elif 'open flipkart' in self.query:
                webbrowser.open("https://www.flipkart.com")
                speak("opening flipkart")

            elif 'open ebay' in self.query:
                webbrowser.open("https://www.ebay.com")
                speak("opening ebay")

            elif 'mail to sister' in self.query:
                try:
                    speak("What should I say?")
                    content = self.takeCommand()
                    to = "*****@*****.**"
                    sendEmail(to, content)
                    speak("Email has been sent!")
                except Exception as e:
                    print(e)
                    speak("Sorry sir. I am not able to send this email")

            elif 'send a mail' in self.query:
                try:
                    speak("What should I say?")
                    content = self.takeCommand()
                    speak("whome should i send")
                    to = input()
                    sendEmail(to, content)
                    speak("Email has been sent !")
                except Exception as e:
                    print(e)
                    speak("I am not able to send this email")

            elif "change name" in self.query:
                speak("What would you like to call me, Sir ")
                assname = self.takeCommand()
                speak("Thanks for naming me")

            elif "what's your name" in self.query or "What is your name" in self.query:
                speak("My friends call me")
                speak(assname)
                print("My friends call me", assname)

            elif 'good bye' in self.query:
                speak("good bye")
                exit()

            elif "shutdown" in self.query:
                speak("shutting down")
                os.system('shutdown -s')

            elif "what\'s up" in self.query or 'how are you' in self.query:
                stMsgs = [
                    'Just doing my thing!', 'I am fine!', 'Nice!',
                    'I am nice and full of energy', 'i am okey ! How are you'
                ]
                ans_q = random.choice(stMsgs)
                speak(ans_q)
                ans_take_from_user_how_are_you = self.takeCommand()
                if 'fine' in ans_take_from_user_how_are_you or 'happy' in ans_take_from_user_how_are_you or 'okey' in ans_take_from_user_how_are_you:
                    speak('okey..')
                elif 'not' in ans_take_from_user_how_are_you or 'sad' in ans_take_from_user_how_are_you or 'upset' in ans_take_from_user_how_are_you:
                    speak('oh sorry..')

            elif 'make you' in self.query or 'created you' in self.query or 'develop you' in self.query:
                ans_m = " For your information shivam gupta Created me ! I give Lot of Thannks to Him "
                print(ans_m)
                speak(ans_m)

            elif "who are you" in self.query or "about you" in self.query or "your details" in self.query:
                about = "I am Bella an A I based computer program but i can help you lot like a your close friend ! i promise you ! Simple try me to give simple command ! like playing music or video from your directory i also play video and song from web or online ! i can also entain you i so think you Understand me ! ok Lets Start "
                print(about)
                speak(about)

            elif "hello" in self.query or "hello Bella" in self.query:
                hel = "Hello Sir ! How May i Help you.."
                print(hel)
                speak(hel)

            elif "your name" in self.query or "sweat name" in self.query:
                na_me = "Thanks for Asking my name my self ! Bella"
                print(na_me)
                speak(na_me)

            elif "you feeling" in self.query:
                print("feeling Very sweet after meeting with you")
                speak("feeling Very sweet after meeting with you")

            elif 'exit' in self.query or 'abort' in self.query or 'stop' in self.query or 'bye' in self.query or 'quit' in self.query:
                ex_exit = 'I feeling very sweet after meeting with you but you are going! i am very sad'
                speak(ex_exit)
                exit()

            elif "calculate" in self.query:

                app_id = "UA6V6W-X2PXG24J98"
                client = wolframalpha.Client("UA6V6W-X2PXG24J98")
                indx = self.query.lower().split().index('calculate')
                self.query = self.query.split()[indx + 1:]
                res = client.query(' '.join(self.query))
                answer = next(res.results).text
                print("The answer is " + answer)
                speak("The answer is " + answer)

            elif 'news' in self.query:

                try:
                    jsonObj = urlopen(
                        '''https://newsapi.org/v2/top-headlines?country=in&apiKey=9655f3abc604484586897775536c8622'''
                    )
                    data = json.load(jsonObj)
                    i = 1

                    speak('here are some top news from the times of india')
                    print('''=============== TIMES OF INDIA ============''' +
                          '\n')

                    for item in data['articles']:

                        print(str(i) + '. ' + item['title'] + '\n')
                        print(item['description'] + '\n')
                        speak(str(i) + '. ' + item['title'] + '\n')
                        i += 1
                except Exception as e:

                    print(str(e))

            elif 'lock window' in self.query:
                speak("locBella the device")
                subprocess.call("shutdown / h")

            elif 'shutdown system' in self.query:
                speak("Hold On a Sec ! Your system is on its way to shut down")
                os.system('shutdown -s')

            elif 'empty recycle bin' in self.query:
                winshell.recycle_bin().empty(confirm=False,
                                             show_progress=False,
                                             sound=True)
                speak("Recycle Bin Recycled")

            elif "don't listen" in self.query or "stop listening" in self.query:
                speak(
                    "for how much time you want to stop jarvis from listening commands"
                )
                a = int(self.takeCommand())
                time.sleep(a)
                print(a)

            elif "where is" in self.query:
                self.query = self.query.replace("where is", "")
                location = self.query
                speak("User asked to Locate")
                speak(location)
                webbrowser.open("https://www.google.nl / maps / place/" +
                                location + "")

            elif "restart" in self.query:
                subprocess.call(["shutdown", "/r"])

            elif "hibernate" in self.query or "sleep" in self.query:
                speak("Hibernating")
                subprocess.call("shutdown / h")

            elif "log off" in self.query or "sign out" in self.query:
                speak(
                    "Make sure all the application are closed before sign-out")
                time.sleep(5)
                subprocess.call(["shutdown", "/l"])

            elif "write a note" in self.query:
                speak("What should i write, sir")
                note = self.takeCommand()
                file = open('jarvis.txt', 'w')
                speak("Sir, Should i include date and time")
                snfm = self.takeCommand()
                if 'yes' in snfm or 'sure' in snfm:
                    strTime = datetime.datetime.now().strftime("% H:% M:% S")
                    file.write(strTime)
                    file.write(" :- ")
                    file.write(note)
                else:
                    file.write(note)

            elif "show note" in self.query:
                speak("Showing Notes")
                file = open("jarvis.txt", "r")
                print(file.read())
                speak(file.read(6))

            elif "send message" in self.query:
                # You need to create an account on Twilio to use this service
                account_sid = 'AC82d4360947707beb34f155ae1d19d31b'
                auth_token = '43b4aa339a59e50e115fd8954580dae3'
                client = Client(account_sid, auth_token)

                message = client.messages \
                .create(
                    body="Join Earth's mightiest heroes. Like Kevin Bacon.",
                    from_='+18707298456',
                    to='7014217098'
                )

                print(message.sid)
                speak("message sent successfully")

            elif "what is" in self.query or "who is" in self.query:

                # Use the same API key
                # that we have generated earlier
                client = wolframalpha.Client("UA6V6W-X2PXG24J98")
                res = client.query(self.query)

                try:
                    print(next(res.results).text)
                    speak(next(res.results).text)
                except StopIteration:
                    print("No results")

            elif 'open command' in self.query:
                codePath = "C:/WINDOWS/system32/cmd.exe"
                os.startfile(codePath)

            elif 'close command' in self.query:
                os.system("taskkill /IM cmd.exe")

            elif 'open notepad' in self.query:
                codePath = "C:\WINDOWS\system32/notepad.exe"
                os.startfile(codePath)

            elif 'close notepad' in self.query:
                os.system("taskkill /IM notepad.exe")

            elif 'open chrome' in self.query:
                codePath = "C:\Program Files (x86)\Google\Chrome\Application/chrome.exe"
                os.startfile(codePath)

            elif 'close chrome' in self.query:
                os.system("taskkill /IM chrome.exe")

            elif 'open word' in self.query:
                codePath = "C:\Program Files\Microsoft Office\root\Office16\WINWORD.EXE"
                os.startfile(codePath)

            elif 'open excel' in self.query:
                codePath = "C:\Program Files\Microsoft Office\root\Office16\excel.exe"
                os.startfile(codePath)

            elif 'open skype' in self.query:
                codePath = "skype.exe"
                os.startfile(codePath)

            elif 'open power point' in self.query:
                codePath = "C:\Program Files\Microsoft Office\root\Office16\POWERPNT.exe"
                os.startfile(codePath)

            elif 'open onenote' in self.query:
                codePath = "C:\Program Files\Microsoft Office\root\Office16\ONENOTE.exe"
                os.startfile(codePath)

            elif 'take screenshot' in self.query or 'take a screenshot' in self.query:
                speak("sir,please tell me the name of this screenshot")
                name = self.takeCommand().lower()
                speak("sir,please hold the screen ,i am taBella a screenshot")
                time.sleep(3)
                img = pyautogui.screenshot()
                img.save(f"{name}.png")
                speak("i am done sir, screenshot is saved ")

            elif 'thank you ' in self.query or 'thanks' in self.query:
                speak("welcome sir")

            elif "weather" in self.query:

                # Google Open weather website
                # to get API of Open weather
                api_key = "6eee755a887428d041cdef4103794fac"
                base_url = "http://api.openweapip thermap.org / data / 2.5 / weather?"
                # speak(" City name ")
                # print("City name : ")
                # city_name = self.takeCommand()
                complete_url = 'api.openweathermap.org/data/2.5/weather?q={jaipur}&appid={6eee755a887428d041cdef4103794fac}'

                response = requests.get(complete_url)
                x = response.json()

                if x["cod"] != "404":
                    y = x["main"]
                    current_temperature = y["temp"]
                    current_pressure = y["pressure"]
                    current_humidiy = y["humidity"]
                    z = x["weather"]
                    weather_description = z[0]["description"]
                    print(" Temperature (in kelvin unit) = " +
                          str(current_temperature) +
                          "\n atmospheric pressure (in hPa unit) =" +
                          str(current_pressure) +
                          "\n humidity (in percentage) = " +
                          str(current_humidiy) + "\n description = " +
                          str(weather_description))

                else:
                    speak(" City Not Found ")

            elif 'location' in self.query:
                speak('What is the location?')
                location = self.takeCommand()
                url = 'https://google.nl/maps/place/' + location + '/&'
                webbrowser.get('chrome').open_new_tab(url)
                speak('Here is the location ' + location)
Example #5
0
    def TaskExecution(self):
        wishMe()
        assname="SAM"
        while True:
            self.query = self.takeCommand().lower()
            #found by SGB-1
            '''
            if 'wikipedia' in self.query:
                try:
                    speak('Searching Wikipedia...')
                    self.query = self.query.replace("Wikipedia", "")
                    results = wikipedia.summary(self.query, sentences=3)
                    speak("According to Wikipedia")
                    speak(results)
                except Exception as e:
                    print(e)
                    speak("I am not able to find please search for other information.")
            '''
            if 'open youtube' in self.query:
                speak("Here you go to Youtube\n")
                webbrowser.open("youtube.com")
                
            #elif 'who is ' in self.query:
             #   speak("")

            elif 'open whatsapp' in self.query:
                speak("Here you go to Whatsapp\n")
                webbrowser.open("web.whatsapp.com")

            elif 'open google' in self.query:
                speak("Here you go to Google\n")
                webbrowser.open("google.com")

            elif 'stack overflow' in self.query:
                speak("Here you go to Stack Over flow.Happy coding")
                webbrowser.open("stackoverflow.com")

            elif 'play music' in self.query or "play song" in self.query:
                speak("Here you go with music")
                music_dir = "D:\\Music"
                songs = os.listdir(music_dir)
                rd = random.choice(songs)
                os.startfile(os.path.join(music_dir, rd))

            elif 'the time' in self.query:
                strTime = datetime.datetime.now().strftime("%I:%M %p")
                speak(f"Sir, the time is {strTime}")

            elif 'open opera' in self.query:
                codePath = r"C:\\Users\\GAURAV\\AppData\\Local\\Programs\\Opera\\launcher.exe"
                os.startfile(codePath)

            elif 'email to gaurav' in self.query:
                try:
                    speak("What should I say?")
                    content = self.takeCommand()
                    to = "Receiver email address"
                    sendEmail(to, content)
                    speak("Email has been sent !")
                except Exception as e:
                    print(e)
                    speak("I am not able to send this email")

            elif 'send a mail' in self.query:
                try:
                    speak("What should I say?")
                    content = self.takeCommand()
                    speak("whom should i send")
                    to = input()
                    sendEmail(to, content)
                    speak("Email has been sent !")
                except Exception as e:
                    print(e)
                    speak("I am not able to send this email")

            elif 'how are you' in self.query:
                speak("I am fine, Thank you")
                speak("How are you, Sir")

            elif 'fine' in self.query or "good" in self.query:
                speak("It's good to know that your fine")

            elif "change my name to" in self.query:
                query = self.query.replace("change my name to", "")
                assname = query

            elif "change name" in self.query:
                speak("What would you like to call me, Sir ")
                assname = self.takeCommand()
                speak("Thanks for naming me")
                
            elif "what's your name" in self.query or "What is your name" in self.query:
                try:
                    speak(f"My friends call me {assname}")
                except Exception as e:
                    print(e)
                    speak("I am not able to understand")
               

            elif 'exit' in self.query or 'you can go now' in self.query:
                speak("Thanks for giving me your time")
                exit()

            elif "who made you" in self.query or "who created you" in self.query:
                speak("I have been created by Subramanya.")

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

            elif "calculate" in self.query:

                app_id = "EPHWP8-W46635H8VG"
                client = wolframalpha.Client(app_id)
                indx = self.query.lower().split().index('calculate')
                query = self.query.split()[indx + 1:]
                res = client.query(' '.join(query))
                answer = next(res.results).text
                print("The answer is " + answer)
                speak("The answer is " + answer)

            elif 'search' in self.query or 'play' in self.query:

                query = self.query.replace("search", "")
                query = self.query.replace("play", "")
                webbrowser.open(query)

            elif "who i am" in self.query:
                speak("If you talk then definitely your human.")

            elif "why you came to world" in self.query:
                speak("Thanks to Subramanya. further It's a secret")

            elif 'power point presentation' in self.query:
                speak("opening Power Point presentation")
                power = r"C:\\Users\\subra\\Desktop\\Minor Project\\Presentation\\Voice Assistant.pptx"
                os.startfile(power)

            elif 'is love' in self.query:
                speak("It is 7th sense that destroy all other senses")

            elif "who are you" in self.query:
                speak("I am your virtual assistant created by Subramanya")

            elif 'reason for you' in self.query:
                speak("I was created as a Minor project by Mister Subramanya ")

            elif 'change background' in self.query:
                ctypes.windll.user32.SystemParametersInfoW(20, 0, "Location of wallpaper", 0)
                speak("Background changed successfully")

            elif 'open bluestack' in self.query:
                appli = r"C:\\ProgramData\\BlueStacks\\Client\\Bluestacks.exe"
                os.startfile(appli)

            elif 'news' in self.query:

                try:
                    jsonObj = urlopen('''http://newsapi.org/v2/top-headlines?country=in&category=technology&apiKey=c3285e34e7cd41de9452043e67f873f6''')
                    data = json.load(jsonObj)
                    i = 1

                    speak('here are some top news Sir.')

                    for item in data['articles']:
                        speak(str(i) + '. ' + item['title'] + '\n')
                        speak(item['description'] + '\n')
                        #speak(str(i) + '. ' + item['title'] + '\n')
                        i += 1
                except Exception as e:
                    print(str(e))

            elif 'lock system' in self.query:
                speak("locking the device")
                ctypes.windll.user32.LockWorkStation()

            elif 'shutdown system' in self.query:
                speak("Hold On a Sec ! Your system is on its way to shut down")
                subprocess.call('shutdown / p /f')

            elif 'empty recycle bin' in self.query:
                winshell.recycle_bin().empty(confirm=False, show_progress=False, sound=True)
                speak("Recycle Bin Recycled")

            elif "don't listen" in self.query or "stop listening" in self.query:
                speak("for how much time you want to stop jarvis from listening commands")
                a = int(self.takeCommand())
                time.sleep(a)
                print(a)

            elif "where is" in self.query:
                query = self.query.replace("where is", "")
                location = query
                speak("Hold on sir, I will show you where " + location + " is.")
                speak(location)
                webbrowser.open("https://www.google.nl / maps / place/" + location + "")

            # elif "camera" in query or "take a photo" in query:
            # ec.capture(0, "Jarvis Camera ", "img.jpg")

            elif "restart" in self.query:
                subprocess.call(["shutdown", "/r"])

            elif "hibernate" in self.query or "sleep" in self.query:
                speak("Hibernating")
                subprocess.call("shutdown / h")

            elif "log off" in self.query or "sign out" in self.query:
                speak("Make sure all the application are closed before sign-out")
                time.sleep(5)
                subprocess.call(["shutdown", "/l"])

            elif "write a note" in self.query:
                speak("What should i write, sir")
                note = self.takeCommand()
                file = open('jarvis.txt', 'w')
                speak("Sir, Should i include date and time")
                snfm = self.takeCommand()
                if 'yes' in snfm or 'sure' in snfm:
                    strTime = datetime.datetime.now().strftime("% H:% M:% S")
                    file.write(strTime)
                    file.write(" :- ")
                    file.write(note)
                else:
                    file.write(note)

            elif "show note" in self.query:
                speak("Showing Notes")
                file = open("jarvis.txt", "r")
                print(file.read())
                speak(file.read(6))
          
                
            elif "update assistant" in self.query:
                speak("After downloading file please replace this file with the downloaded one")
                url = '# url after uploading file'
                r = requests.get(url, stream=True)

                with open("Voice.py", "wb") as Pypdf:

                    total_length = int(r.headers.get('content-length'))

                    for ch in progress.bar(r.iter_content(chunk_size=2391975),
                                           expected_size=(total_length / 1024) + 1):
                        if ch:
                            Pypdf.write(ch)

            # NPPR9-FWDCX-D2C8J-H872K-2YT43
            elif "jarvis" in self.query:

                wishMe()
                speak("Jarvis 1 point o in your service Mister")
                speak(assname)

            elif "weather" in self.query:

                # Google Open weather website
                # to get API of Open weather
                api_key = "27e77758bd211846998f3629b6c519af"
                base_url = "http://api.openweathermap.org / data / 2.5 / weather?"
                speak(" City name ")
                city_name = self.takeCommand()
                complete_url = base_url + "appid =" + api_key + "&q =" + city_name
                response = requests.get(complete_url)
                x = response.json()

                if x["cod"] != "404":
                    y = x["main"]
                    current_temperature = y["temp"]
                    current_pressure = y["pressure"]
                    current_humidiy = y["humidity"]
                    z = x["weather"]
                    weather_description = z[0]["description"]
                    print(" Temperature (in kelvin unit) = " + str(
                        current_temperature) + "\n atmospheric pressure (in hPa unit) =" + str(
                        current_pressure) + "\n humidity (in percentage) = " + str(
                        current_humidiy) + "\n description = " + str(weather_description))

                else:
                    speak(" City Not Found ")

            elif "send message" in self.query:
                # You need to create an account on Twilio to use this service
                account_sid = os.environ['AC765eb606691c6a0d3638ddff5426843e']
                auth_token = os.environ['c7179a2091973228050a14907679b8af']
                client = Client(account_sid, auth_token)

                message = client.messages \
                    .create(
                        body='This is the testing',
                        from_='+13017615956',
                        to='+919008059668'
                    )

                print(message.sid)

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

            elif "Good Morning" in self.query:
                speak("A warm" + query)
                speak("How are you Mister")
                speak(assname)

            # most asked question from google Assistant
            elif "will you be my gf" in self.query or "will you be my bf" in self.query:
                speak("I'm not sure about, may be you should give me some time")

            elif "how are you" in self.query:
                speak("I'm fine, glad you me that")

            elif "i love you" in self.query:
                speak("It's hard to understand")

            elif "what is" in self.query or "who is" in self.query:

                # Use the same API key
                # that we have generated earlier
                client = wolframalpha.Client("EPHWP8-W46635H8VG")
                res = client.query(self.query)

                try:
                    speak(next(res.results).text)
                except StopIteration:
                    print("No results")

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

            elif "open notepad" in self.query:
                speak("Ok sir, i got it")
                os.startfile("C:\\Windows\\system32\\notepad.exe")

            elif "close notepad" in self.query:
                speak("Ok sir, i got it")
                os.system("taskkill /f /im notepad.exe")

            elif "close browser" in self.query:
                speak("Ok sir, i got it")
                os.system("taskkill /f /im chrome.exe")

            elif "open adobe reader" in self.query:
                os.startfile("C:\\Program Files (x86)\\Adobe\\Acrobat DC\\Acrobat\\Acrobat.exe")

            elif "close adobe reader" in self.query:
                speak("Ok sir, i got it")
                os.system("taskkill /f /im Acrobat.exe")

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

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

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

            elif "open google" in self.query:
                speak("Sir what should i search on google")
                cm = self.takeCommand().lower()
                webbrowser.open(f"{cm}")

            elif "play on youtube" in self.query:
                speak("Sir which song you want to listen.")
                u = self.takeCommand().lower()
                kit.playonyt(f"{u}")

            elif "no thanks" in self.query:
                speak("Thanks for assisting me sir, have a good day.")
                sys.exit()

            elif "where i am" in self.query or "where we are" in self.query:
                speak("wait sir, let me check")
                try:
                    ipAdd = requests.get('https://api.ipify.org').text
                    print(ipAdd)
                    url = 'https://get.geojs.io/v1/ip/geo/' + ipAdd + '.json'
                    geo_requests = requests.get(url)
                    geo_data = geo_requests.json()
                    city = geo_data['city']
                    country = geo_data['country']
                    speak(f"Sir im not sure but i think we are in {city} city of {country} country")

                except Exception as e:
                    speak("Sorry sir, Due to network issue i am unable to find where we are.")
                    pass

            elif "instagram profile" in self.query or "profile on instagram" in self.query:
                speak("Please enter username correctly")
                name = input("Enter user name:")
                webbrowser.open(f"https://www.instagram.com/{name}")
                speak(f"Sir here is the profile of the user {name}")
                time.sleep(5)
                speak("sir would you like to download the profile picture of the account?")
                condition = self.takeCommand().lower()
                if "yes" in condition:
                    mod = instaloader.Instaloader()
                    mod.download_profile(name, profile_pic_only=True)
                    speak("its done sir, saved picture can locate in main folder. Now im ready")
                else:
                    pass

            elif "take screenshot" in self.query or "take a screenshot" in self.query:
                speak("Sir please tell me the name of the screenshot file")
                name = self.takeCommand().lower()
                speak("Sir please hold the screen for few seconds, i am taking screenshot")
                time.sleep(3)
                img = pyautogui.screenshot()
                img.save(f"{name}.png")
                speak("I am done sir, screenshot is saved in main folder, im ready for next command")

            elif "switch the window" in self.query:
                pyautogui.keyDown("alt")
                pyautogui.press("tab")
                time.sleep(1)
                pyautogui.keyUp("alt")

            elif "what\'s up" in self.query or 'how are you' in self.query:
                stMsgs = ['Just doing my thing!', 'I am fine!', 'Nice!', 'I am nice and full of energy']
                speak(random.choice(stMsgs))

            elif 'nothing' in self.query or 'abort' in self.query or 'stop' in self.query:
                speak('okay')
                speak('Bye Boss, have a good day.')
                sys.exit()

            elif 'hello' in self.query:
                speak('Hello Boss')

            elif 'bye' in self.query:
                speak('Bye Boss, have a good day.')
                sys.exit()

            elif 'voice' in self.query:
                if 'female' in self.query:
                    engine.setProperty('voice', voices[1].id)
                else:
                    engine.setProperty('voice', voices[0].id)
                speak("Hello Sir, I have switched my voice. How is it?")


            elif 'remember that' in self.query:
                speak("what should i remember sir")
                rememberMessage = self.takeCommand()
                speak("you said me to remember" + rememberMessage)
                remember = open('data.txt', 'w')
                remember.write(rememberMessage)
                remember.close()

            elif 'do you remember anything' in self.query:
                remember = open('data.txt', 'r')
                speak("you said me to remember that" + remember.read())
Example #6
0
        # most asked question from google Assistant
        elif "will you be my gf" in voice_command or "will you be my bf" in voice_command:
            speak("I'm not sure about, may be you should give me some time")

        elif "how are you" in voice_command:
            speak("I'm fine, glad you me that")

        elif "i love you" in voice_command:
            speak("It's hard to understand")

        elif "what is" in voice_command or "who is" in voice_command:

            # Use the same API key
            # that we have generated earlier

            client = wolframalpha.Client("Clien_id")

            res = client.query(voice_command)

            try:
                print(next(res.results).text)
                speak(next(res.results).text)
            except StopIteration:
                results1 = wikipedia.summary(voice_command, sentences=5)
                print(results1)
                speak(results1)
            # elif "" in voice_command:
        # Command go here
        # For adding more commands
def sendEmail(to, content): 
    server = smtplib.SMTP('smtp.gmail.com', 587) 
    server.ehlo() 
    server.starttls() 
      
    # Enable low security in gmail 
    server.login('your email id', 'your email passowrd') 
    server.sendmail('your email id', to, content) 
    server.close() 
    if __name__ == '__main__': 
    clear = lambda: os.system('cls') 
      
    # This Function will clean any 
    # command before execution of this python file 
    clear() 
    wishMe() 
    usrname() 
      
    while True: 
          
        query = takeCommand().lower() 
          
        # All the commands said by user will be  
        # stored here in 'query' and will be 
        # converted to lower case for easily  
        # recognition of command 
        if 'wikipedia' in query: 
            speak('Searching Wikipedia...') 
            query = query.replace("wikipedia", "") 
            results = wikipedia.summary(query, sentences = 3) 
            speak("According to Wikipedia") 
            print(results) 
            speak(results) 
  
        elif 'open youtube' in query: 
            speak("Here you go to Youtube\n") 
            webbrowser.open("youtube.com") 
  
        elif 'open google' in query: 
            speak("Here you go to Google\n") 
            webbrowser.open("google.com") 
  
        elif 'open stackoverflow' in query: 
            speak("Here you go to Stack Over flow.Happy coding") 
            webbrowser.open("stackoverflow.com")    
  
        elif 'play music' in query or "play song" in query: 
            speak("Here you go with music") 
            # music_dir = "G:\\Song" 
            music_dir = "C:\\Users\\GAURAV\\Music"
            songs = os.listdir(music_dir) 
            print(songs)     
            random = os.startfile(os.path.join(music_dir, songs[1])) 
  
        elif 'the time' in query: 
            strTime = datetime.datetime.now().strftime("% H:% M:% S")     
            speak(f"Sir, the time is {strTime}") 
  
        elif 'open opera' in query: 
            codePath = r"C:\\Users\\GAURAV\\AppData\\Local\\Programs\\Opera\\launcher.exe"
            os.startfile(codePath) 
  
        elif 'email to gaurav' in query: 
            try: 
                speak("What should I say?") 
                content = takeCommand() 
                to = "Receiver email address"    
                sendEmail(to, content) 
                speak("Email has been sent !") 
            except Exception as e: 
                print(e) 
                speak("I am not able to send this email") 
  
        elif 'send a mail' in query: 
            try: 
                speak("What should I say?") 
                content = takeCommand() 
                speak("whome should i send") 
                to = input()     
                sendEmail(to, content) 
                speak("Email has been sent !") 
            except Exception as e: 
                print(e) 
                speak("I am not able to send this email") 
  
        elif 'how are you' in query: 
            speak("I am fine, Thank you") 
            speak("How are you, Sir") 
  
        elif 'fine' in query or "good" in query: 
            speak("It's good to know that your fine") 
  
        elif "change my name to" in query: 
            query = query.replace("change my name to", "") 
            assname = query 
  
        elif "change name" in query: 
            speak("What would you like to call me, Sir ") 
            assname = takeCommand() 
            speak("Thanks for naming me") 
  
        elif "what's your name" in query or "What is your name" in query: 
            speak("My friends call me") 
            speak(assname) 
            print("My friends call me", assname) 
  
        elif 'exit' in query: 
            speak("Thanks for giving me your time") 
            exit() 
  
        elif "who made you" in query or "who created you" in query:  
            speak("I have been created by Gaurav.") 
              
        elif 'joke' in query: 
            speak(pyjokes.get_joke()) 
              
        elif "calculate" in query:  
              
            app_id = "Wolframalpha api id" 
            client = wolframalpha.Client(app_id) 
            indx = query.lower().split().index('calculate')  
            query = query.split()[indx + 1:]  
            res = client.query(' '.join(query))  
            answer = next(res.results).text 
            print("The answer is " + answer)  
            speak("The answer is " + answer)  
  
        elif 'search' in query or 'play' in query: 
              
            query = query.replace("search", "")  
            query = query.replace("play", "")           
            webbrowser.open(query)  
  
        elif "who i am" in query: 
            speak("If you talk then definately your human.") 
  
        elif "why you came to world" in query: 
            speak("Thanks to Gaurav. further It's a secret") 
  
        elif 'power point presentation' in query: 
            speak("opening Power Point presentation") 
            power = r"C:\\Users\\GAURAV\\Desktop\\Minor Project\\Presentation\\Voice Assistant.pptx"
            os.startfile(power) 
  
        elif 'is love' in query: 
            speak("It is 7th sense that destroy all other senses") 
  
        elif "who are you" in query: 
            speak("I am your virtual assistant created by Gaurav") 
  
        elif 'reason for you' in query: 
            speak("I was created as a Minor project by Mister Gaurav ") 
  
        elif 'change background' in query: 
            ctypes.windll.user32.SystemParametersInfoW(20,  
                                                       0,  
                                                       "Location of wallpaper", 
                                                       0) 
            speak("Background changed succesfully") 
  
        elif 'open bluestack' in query: 
            appli = r"C:\\ProgramData\\BlueStacks\\Client\\Bluestacks.exe"
            os.startfile(appli) 
  
        elif 'news' in query: 
              
            try:  
                jsonObj = urlopen('''https://newsapi.org / v1 / articles?source = the-times-of-india&sortBy = top&apiKey =\\times of India Api key\\''') 
                data = json.load(jsonObj) 
                i = 1
                  
                speak('here are some top news from the times of india') 
                print('''=============== TIMES OF INDIA ============'''+ '\n') 
                  
                for item in data['articles']: 
                      
                    print(str(i) + '. ' + item['title'] + '\n') 
                    print(item['description'] + '\n') 
                    speak(str(i) + '. ' + item['title'] + '\n') 
                    i += 1
            except Exception as e: 
                  
                print(str(e)) 
  
          
        elif 'lock window' in query: 
                speak("locking the device") 
                ctypes.windll.user32.LockWorkStation() 
  
        elif 'shutdown system' in query: 
                speak("Hold On a Sec ! Your system is on its way to shut down") 
                subprocess.call('shutdown / p /f') 
                  
        elif 'empty recycle bin' in query: 
            winshell.recycle_bin().empty(confirm = False, show_progress = False, sound = True) 
            speak("Recycle Bin Recycled") 
  
        elif "don't listen" in query or "stop listening" in query: 
            speak("for how much time you want to stop jarvis from listening commands") 
            a = int(takeCommand()) 
            time.sleep(a) 
            print(a) 
  
        elif "where is" in query: 
            query = query.replace("where is", "") 
            location = query 
            speak("User asked to Locate") 
            speak(location) 
            webbrowser.open("https://www.google.nl / maps / place/" + location + "") 
  
        elif "camera" in query or "take a photo" in query: 
            ec.capture(0, "Jarvis Camera ", "img.jpg") 
  
        elif "restart" in query: 
            subprocess.call(["shutdown", "/r"]) 
              
        elif "hibernate" in query or "sleep" in query: 
            speak("Hibernating") 
            subprocess.call("shutdown / h") 
  
        elif "log off" in query or "sign out" in query: 
            speak("Make sure all the application are closed before sign-out") 
            time.sleep(5) 
            subprocess.call(["shutdown", "/l"]) 
  
        elif "write a note" in query: 
            speak("What should i write, sir") 
            note = takeCommand() 
            file = open('jarvis.txt', 'w') 
            speak("Sir, Should i include date and time") 
            snfm = takeCommand() 
            if 'yes' in snfm or 'sure' in snfm: 
                strTime = datetime.datetime.now().strftime("% H:% M:% S") 
                file.write(strTime) 
                file.write(" :- ") 
                file.write(note) 
            else: 
                file.write(note) 
          
        elif "show note" in query: 
            speak("Showing Notes") 
            file = open("jarvis.txt", "r")  
            print(file.read()) 
            speak(file.read(6)) 
  
        elif "update assistant" in query: 
            speak("After downloading file please replace this file with the downloaded one") 
            url = '# url after uploading file'
            r = requests.get(url, stream = True) 
              
            with open("Voice.py", "wb") as Pypdf: 
                  
                total_length = int(r.headers.get('content-length')) 
                  
                for ch in progress.bar(r.iter_content(chunk_size = 2391975), 
                                       expected_size =(total_length / 1024) + 1): 
                    if ch: 
                      Pypdf.write(ch) 
                      
        # NPPR9-FWDCX-D2C8J-H872K-2YT43 
        elif "jarvis" in query: 
              
            wishMe() 
            speak("Jarvis 1 point o in your service Mister") 
            speak(assname) 
  
        elif "weather" in query: 
              
            # Google Open weather website 
            # to get API of Open weather  
            api_key = "Api key" 
            base_url = "http://api.openweathermap.org / data / 2.5 / weather?"
            speak(" City name ") 
            print("City name : ") 
            city_name = takeCommand() 
            complete_url = base_url + "appid =" + api_key + "&q =" + city_name 
            response = requests.get(complete_url)  
            x = response.json()  
              
            if x["cod"] != "404":  
                y = x["main"]  
                current_temperature = y["temp"]  
                current_pressure = y["pressure"]  
                current_humidiy = y["humidity"]  
                z = x["weather"]  
                weather_description = z[0]["description"]  
                print(" Temperature (in kelvin unit) = " +str(current_temperature)+"\n atmospheric pressure (in hPa unit) ="+str(current_pressure) +"\n humidity (in percentage) = " +str(current_humidiy) +"\n description = " +str(weather_description))  
              
            else:  
                speak(" City Not Found ") 
              
        elif "send message " in query: 
                # You need to create an account on Twilio to use this service 
                account_sid = 'Account Sid key'
                auth_token = 'Auth token'
                client = Client(account_sid, auth_token) 
  
                message = client.messages \ 
                                .create( 
                                    body = takeCommand(), 
                                    from_='Sender No', 
                                    to ='Receiver No'
                                ) 
  
                print(message.sid) 
  
        elif "wikipedia" in query: 
            webbrowser.open("wikipedia.com") 
  
        elif "Good Morning" in query: 
            speak("A warm" +query) 
            speak("How are you Mister") 
            speak(assname) 
  
        # most asked question from google Assistant 
        elif "will you be my gf" in query or "will you be my bf" in query:    
            speak("I'm not sure about, may be you should give me some time") 
  
        elif "how are you" in query: 
            speak("I'm fine, glad you me that") 
  
        elif "i love you" in query: 
            speak("It's hard to understand") 
  
        elif "what is" in query or "who is" in query: 
              
            # Use the same API key  
            # that we have generated earlier 
            client = wolframalpha.Client("API_ID") 
            res = client.query(query) 
              
            try: 
                print (next(res.results).text) 
                speak (next(res.results).text) 
            except StopIteration: 
                print ("No results")