def WikiHowAgent(content):
    #parse the question from the message to howdoi
    pos = content.lower().find("!howdoi")
    #if no question was exist
    Question = content[pos + len("!howdoi"):]
    if Question.lower().find("--wikihow"):
        Question = Question.replace("--wikihow", "")
    #pywikihow to find one answer
    try:
        how_tos = search_wikihow(Question, 1)
        how_to = how_tos[0].as_dict()
        n_step = how_to['n_steps']
        steps = how_to['steps']
        if n_step < 20:
            summary = []
            for i in range(n_step):
                summary.append(steps[i]['summary'])
            summary = '\n'.join([str(elem) for elem in summary])
            Answer = summary
        else:
            summary = []
            for i in range(20):
                summary.append(steps[i]['summary'])
            summary = '\n'.join([str(elem) for elem in summary])
            Answer = summary + " \n \n Check this link for more results: " + how_to[
                'url']
    except:
        Answer = 0
    return Answer
Exemplo n.º 2
0
def search_howto(term: str):
    how_tos = search_wikihow(term, max_results=10)
    res = '*Select the article you want to view.*\n'
    for index, item in enumerate(how_tos):
        res += f'{index + 1} - {item}\n\n'
    return {
        'articles': res,
        'size': len(how_tos)
    }
Exemplo n.º 3
0
def Info():
    try:
        mk = query.replace("genius", "")
        max_result = 1
        how_to_fun = search_wikihow(mk, max_result)
        assert len(how_to_fun) == 1
        how_to_fun[0].print()
        Speak1(how_to_fun[0].summary)

    except Exception as e:
        Speak("Speak again")
Exemplo n.º 4
0
def get_howto_result(command):
    assistant.speak(f'Searching database for {command}')
    try:
        max_results = 1
        how_to = search_wikihow(command, max_results)
        assert len(how_to) == 1
        how_to[0].print()
        assistant.speak(how_to[0].summary)
        assistant.speak('Anything else sir?')
        command = assistant.takeCommand()
        if 'no' in command:
            assistant.speak('Okay sir.')
        elif 'repeat' in command:
            assistant.speak(how_to[0].summary)
        elif 'how to' in command:
            get_howto_result(command)
        elif 'yes' in command:
            assistant.speak('What sir?')
            newcommand = assistant.takeCommand()
            get_howto_result(newcommand)
    except:
        assistant.speak(f'No information on {command}')
        assistant.speak('Do you wish to know about something else?')
        newcommand = assistant.takeCommand()
        if 'no' in newcommand:
            assistant.speak('Okay sir.')
        elif 'yes' in newcommand:
            assistant.speak('What sir?')
            newcommand = assistant.takeCommand()
            if 'i want to know about' in newcommand:
                newcommand = newcommand.replace('i want to know about', '')
            get_howto_result(newcommand)
        elif 'none' in newcommand or newcommand is None:
            pass
        else:
            assistant.speak('I did not quite get you.')
Exemplo n.º 5
0
from pywikihow import WikiHow, search_wikihow

max_results = 1  # default for optional argument is 10
how_tos = search_wikihow("how to learn programming", max_results)
assert len(how_tos) == 1
how_tos[0].print()

# for efficiency and to get unlimited entries, the best is to use the generator
for how_to in WikiHow.search("how to learn python"):
    how_to.print()
Exemplo n.º 6
0
    def clicked(self):
        # wishMe()
        query = takecommand()
        self.userText.set('listening....')
        self.userText.set(query)

        if query != None:
            query = query.lower()

            # ------It will open youtube after taking command from user-------#
            if 'youtube' in query:
                speak('opening youtube')
                webbrowser.open("youtube.com")

            # User can search on wikipedia by giving command like According to wikipedia#
            elif 'wikipedia' in query:
                speak('Searching...')
                query = query.replace("wikipedia", "")
                results = wikipedia.summary(query, sentences=3)
                speak("According to wikipedia")
                speak(results)

            #-To Search like how to cook... or how to use... first user have to say "activate" and
            # will speak up  How to do mode is activated and take input from user if user input recognized clearly
            # AIMaya will speak up some output-#
            elif "activate" in query:
                speak(" How To Do Mode is Activated")
                how = takecommand()
                max_result = 1
                how_to = search_wikihow(how, max_result)
                assert len(how_to) == 1
                how_to[0].print()
                speak(how_to[0].summary)

            # User can search on wikipedia by giving command like According to wikipedia or who is#
            elif 'who is' in query:
                query = query.replace("wikipedia", "")
                results = wikipedia.summary(query, sentences=3)
                speak("According to wikipedia")
                speak(results)

            elif 'define' in query:
                query = query.replace("wikipedia", "")
                results = wikipedia.summary(query, sentences=2)
                speak("According to wikipedia")
                speak(results)

            #----Command open facebook & it will open facebook------#
            elif 'facebook' in query:
                speak('opening facebook')
                webbrowser.open("facebook.com")

            elif 'how are you' in query:
                speak("I am Fine Sir Thank You for Asking")

            elif "tell me your name" in query:
                speak("My name is Mayaa")

            #-importing pyjokes will perform some random jokes -#
            elif 'joke' in query:
                listen = (pyjokes.get_joke())
                speak(listen)
                print(listen)

            elif 'How are you' in query:
                speak('I am Fine, Thank You so much for asking')

            #-for video playlist from local disk -#
            elif 'video' in query:
                music_dir = 'D:\\Playlist'
                songs = os.listdir(music_dir)
                print(songs)
                os.startfile(os.path.join(music_dir, songs[0]))

            #-for playing task on youtube like songs-#
            elif 'play' in query:
                song = query.replace('play', '')
                mood = ('playing' + song)
                pywhatkit.playonyt(song)
                speak(mood)

            #-to activate calculator just say open calculator-#
            elif 'open calculator' in query:
                try:
                    r = src.Recognizer()
                    with src.Microphone() as source:
                        speak("Okay, What you want to calculate")
                        print("Listening...")
                        r.pause_threshold = 1
                        r.adjust_for_ambient_noise(source)
                        audio = r.listen(source)
                    my_string = r.recognize_google(audio)
                    print(my_string)

                    def get_operator_fn(op):
                        return {
                            '+': operator.add,  # plus
                            '-': operator.sub,  # minus
                            '*': operator.mul,  # multiplied by
                            '/': operator.__truediv__,  # divided
                        }[op]

                    def eval_binary_expr(op1, oper, op2):  # 6 plus 3
                        op1, op2 = int(op1), int(op2)
                        return get_operator_fn(oper)(op1, op2)

                    speak("Your Result is")
                    speak(eval_binary_expr(*(my_string.split())))
                except:
                    speak(
                        'Sorry, I am not able to recall the calculation task. Please try again'
                    )

            #-for current time -#
            elif 'time' in query:
                strTime = datetime.datetime.now().strftime("%I:%M %p")
                speak(f"The Current time is {strTime}")

            #
            elif 'thank you' in query:
                speak("My Pleasure")

            #-it will open google search for searching-#
            elif 'google' in query:
                webbrowser.open("google.com")

            elif 'softwarica' in query or 'software Rika' in query or 'software QA' in query:
                speak(
                    'I know, Softwarica is a college of IT and e-Commerce in kathmandu nepal,\
                      Softwarica is collaborated with Coventry University which is located in UK'
                )

            #--Opening Campus 4.0 with this given two query --#
            elif 'Campus 4.0' in query or 'campus' in query:
                speak('Opening')
                webbrowser.open('https://campus.softwarica.edu.np/')

            #--For opening google map--#
            elif 'map' in query or 'google map' in query:
                speak('opening')
                webbrowser.open('https://www.google.com/maps')
Exemplo n.º 7
0
def TaskExecution():
    p.press('esc')
    speak("Verification Successfully")
    speak("Welcome back Satyam sir")
    wishMe()
    while True:
        # if 1:
        query = takeCmd()

        # logic to executing task based on query.
        if "wikipedia" in query:
            speak("Searching wikipedia....")
            query = query.replace("Wikipedia", "")
            results = wikipedia.summary(query, sentences=2)
            speak("According to wikipedia")
            speak(results)

        elif "where i am" in query or "where we are" in query:
            speak("wait sir, let me check")
            ipAdd = get("https://api.ipify.org").text
            print(ipAdd)
            try:
                url = requests.get('https://ipinfo.io/json').json()
                city = url['city']
                region = url['region']
                country = url['country']
                speak(
                    f"Sir, I am not sure, but we are in {city} of {country}.")
            except Exception as e:
                speak(
                    "Sorry sir, due to network issue I am not able to find the location."
                )
                pass

        elif "take screenshot" in query:
            speak("Sir, please tell me the name for this screenshot file.")
            name = takeCmd().lower()
            speak(
                "Please sir, hold the screen for few seconds, I am taking screenshot"
            )
            time.sleep(3)
            img = p.screenshot()
            img.save(f"{name}.png")
            speak("I am done sir, the screenshot is saved in our main folder.")

        elif "do some calculation" in query or "can you calculate" in query:
            r = sr.Recognizer()
            with sr.Microphone() as source:
                speak("Say what you want to calculate, example 2 plus 2 ")
                print("listening...")
                r.adjust_for_ambient_noise(source)
                audio = r.listen(source)
            my_str = r.recognize_google(audio)
            print(my_str)

            def get_op(op):
                return {
                    '+': calculator.Add,  # plus
                    '-': calculator.Sub,  # minus
                    'x': calculator.Multi,  # multiplied by
                    '/': calculator.Div,  # divided
                }[op]

            def eval_binary_expr(op1, oper, op2):
                op1, op2 = int(op1), int(op2)
                return get_op(oper)(op1, op2)

            speak(f"Your result is: {eval_binary_expr(*(my_str.split()))}")
            # speak()

        elif "open notepad" in query:
            npath = "C:\\WINDOWS\\system32\\notepad.exe"
            os.startfile(npath)
            speak("Opening notepad fou you")

        elif "open command prompt" in query:
            os.system("start cmd")
            speak("opening command prompt for you")

        elif "open youtube" in query:
            speak("Sir, What should I search on YouTube")
            cmd = takeCmd().lower()
            kit.playonyt(cmd)
            speak("Opening youtube")

        elif "play online music" in query:
            text = "Sir, Which song you want to listen"
            speak(text)
            scm = takeCmd().lower()
            kit.playonyt(scm)

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

        elif "open microsoft browser" in query:
            googlePath = "C:\\Program Files (x86)\\Microsoft\\Edge\\Application"
            speak("Sir, What should i search on edge")
            cm = takeCmd().lower()
            webbrowser.open(cm)
            speak("Opening microsoft browser")

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

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

        elif "play music" in query:
            music_dir = "C:\\Users\\hp\\Music"
            songs = os.listdir(music_dir)
            musicNumber = random.randint(0, len(songs))
            os.startfile(os.path.join(music_dir, songs[musicNumber]))
            speak("playing music" + songs[musicNumber])

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

        elif "the date" in query:
            strDate = datetime.date.today()
            speak(f"Sir, The date is {strDate}")

        elif "the day" in query:

            def findDay():
                day = datetime.date.today().weekday()
                return calendar.day_name[day]

            date = datetime.date.today()
            weekDay = findDay()
            print(f"{weekDay} Sir")
            speak(f"{weekDay} Sir")

        elif "open code" in query:
            codePath = "C:\\Users\\hp\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe"
            os.startfile(codePath)
            speak("Opening VS Code")

        elif "open pycharm" in query:
            pathOfCode = "C:\\Program Files\\JetBrains\\PyCharm Community Edition 2021.1\\bin\\pycharm64.exe"
            os.startfile(pathOfCode)
            speak("Opening PyCharm")

        elif "open intell jdea" in query:
            intelljpath = "C:\\Program Files\\JetBrains\\IntelliJ IDEA Community Edition 2021.1.1\\bin\\idea64.exe"
            os.startfile(intelljpath)
            speak("Opening Intell JDEA")

        elif "open studio" in query:
            obsPath = "C:\\Program Files\\obs-studio\\bin\\64bit\\obs64.exe"
            os.startfile(obsPath)
            speak("Opening OBS Studio")

        elif "show me photo" in query:
            photoPath = "C:\\Users\\hp\\OneDrive\\Pictures\\pic"
            photo = os.listdir(photoPath)
            pic = random.randint(0, len(photo))
            os.startfile(os.path.join(photoPath, photo[pic]))
            speak("Opening photo")

        elif "temperature" in query or "weather" in query:
            search = "temperature in jabalpur"
            url = f"https://www.google.com/search?q={search}"
            r = requests.get(url)
            data = bs4.BeautifulSoup(r.text, "html.parser")
            temp = data.find("div", class_="BNeawe").text
            speak(f"current {search} is {temp}")

        elif "activate how to do mode" in query:
            speak(
                "How to do mode is activated please tell me what you want to know"
            )
            how = takeCmd()
            max_result = 1
            how_to = search_wikihow(how, max_result)
            assert len(how_to) == 1
            # how_to[0].print()
            speak(how_to[0].summary)

        elif "volume up" in query:
            p.press("volumeup")

        elif "volume down" in query:
            p.press("volumedown")

        elif "volume mute" in query:
            p.press("volumemute")

        elif "volume unmute" in query:
            p.press("volumeunmute")

        elif "what is my date of birth" in query:
            speak("Sir your date of birth is 26 June")

        elif "when you launch" in query:
            speak("17 March 2021")

        elif "no thanks" in query:
            speak("It my pleasure sir.")

        elif "you can sleep" in query:
            speak("ok sir, I am going to sleep. You can call me any time.")
            break

        # elif "set timer" in query:
        #     speak("For how long I set the timer?")
        #     setTimer = takeCmd()
        #     intSetTime = int(setTimer*60)
        #     time.sleep(intSetTime)
        #     playsound.playsound("Alarm sound.mp3")

        speak("Sir, do you have any other work for me.....")
Exemplo n.º 8
0
        elif 'open fl studio' in command:
            speak("Sure Sir! openinf fl studio")
            os.startfile('D://@Archishman Sinha//FL Studio 20//FL64.exe')

        elif 'are you online' in command:
            speak("I am online and perfect Sir!")

        elif 'greet everyone' in command:
            speak("Hello Everyone!")

        elif 'activate steps mode' in command:
            speak("Steps mode activated. Please tell me what you want to know!")
            how = Command().lower()
            max_res = 1
            res = search_wikihow(how, max_res)
            assert len(res) == 1
            res[0].print()
            speak(res[0].summary)

        elif 'activate cmd mode' in command:
            speak("Activating cmd mode! What command I shall give?")
            com = Command().lower()
            try:
                os.system(f'cmd /k "{com}"')
                continue
            except:
                speak("Sorry cannot execute that command")
                continue
                
        elif 'open instagram' in command:
Exemplo n.º 9
0
                os.system("start excel")
            except Exception as e:
                speak('You might not be having this application')

        elif 'open notepad' in query or 'notepad' in query:
            speak('Opening sir...!!')
            os.system("notepad")

        elif 'shutdown the system' in query or 'shutdown' in query:
            os.system("shutdown /s /t 1")

        elif 'how to do' in query or 'i want to learn ' in query or 'how can i learn this' in query or 'I want to learn' in query or 'how to' in query or 'How to' in query:
            speak('Please tell what you want to do or know ?')
            comm = takeCommand()
            max_results = 1
            how_to = search_wikihow(comm, max_results)
            #assert len(how_to) ==1
            how_to[0].print()
            speak(how_to[0].summary)

        elif 'restart the system' in query:
            os.system("shutdown /r /t 1")

        elif 'calculator' in query:
            speak('Opening sir...!!')
            os.system("calc")

        elif 'command prompt' in query:
            speak('Opening sir...!!')
            os.system("cmd")
Exemplo n.º 10
0
def search_howto_index(term: str, pos: int):
    how_tos = search_wikihow(term)
    return parse_search_howto(how_tos[pos])
Exemplo n.º 11
0
    if 'internet speed' in query:
        Speak("Checking speed")
        test = speedtest.Speedtest()
        downloading = test.download()
        correctDown = int(downloading / 800000)
        uploading = test.upload()
        correctUpload = int(uploading / 800000)
        Speak(
            f"The downloading speed is {correctDown} mbps and uploading is {correctUpload} mbps"
        )

    if 'how to' in query:
        mk = query.replace("genius", "")
        max_result = 1
        how_to_fun = search_wikihow(mk, max_result)
        assert len(how_to_fun) == 1
        how_to_fun[0].print()
        Speak1(how_to_fun[0].summary)

    if 'retype' in query:
        pyautogui.press('/')
        pyautogui.hotkey('ctrl', 'a')
        pyautogui.press('delete')

    if 'type' in query:
        wr = takecommand()
        wr = wr.replace("type", "")
        pyautogui.write(wr)
        pyautogui.press('enter')
Exemplo n.º 12
0
def TaskExecution():
    wish()
    while True:
        query = takecommand()

        # <<<<<<<<<<<<<<<<<<<<<<<<<<<<Logic Building to perform tasks>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

        date = datetime.datetime.today().strftime("%I:%M %p")

        if "time now" in query:
            speak("The time is now " + date + "")

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

        elif 'open google' in query or 'search in google' in query:
            speak("What should i search on Google")
            google = takecommand().lower()
            webbrowser.open(f'www.google.com/search?q=' + google)
            speak("Searching in google...")

        elif 'open bing' in query or 'search in bing' in query:
            speak("What should i search on Bing")
            bing = takecommand().lower()
            webbrowser.open(f'www.bing.com/search?q=' + bing)
            speak("Searching in Bing...")

        elif 'open duckduckgo' in query or 'search in duckduckgo' in query:
            speak("What should i search on DuckDuckGo")
            duck = takecommand().lower()
            webbrowser.open(f'www.duckduckgo.com/search?q=' + duck)
            speak("Searching in DuckDuckGo...")

        elif 'open youtube' in query:
            speak("What do you want me to play")
            youtube = takecommand().lower()
            pywhatkit.playonyt(youtube)
            speak("Playing...")

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

        elif 'open wikipedia' in query:
            speak("What do you want to know from Wikipedia?")
            wiki = takecommand().lower()
            info = wikipedia.summary(wiki, 2)
            speak("According to Wikipedia")
            speak(info)

        elif "open notepad" in query:
            npath = "C:\\Windows\\system32\\notepad.exe"
            os.startfile(npath)

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

        elif 'open task manager' in query:
            tpath = "C:\\Windows\\system32\\Taskmgr.exe"
            os.startfile(tpath)

        elif "open steam" in query:
            spath = "C:\\Program Files (x86)\\Steam\\steam.exe"
            os.startfile(spath)

        elif "open epic games" in query:
            epath = "C:\\Program Files (x86)\\Epic Games\\Launcher\\Portal\\Binaries\\Win32\\EpicGamesLauncher.exe"
            os.startfile(epath)

        elif "open browser" in query:
            bpath = "C:\\Program Files (x86)\\Microsoft\\Edge Dev\\Application\\msedge.exe"
            os.startfile(bpath)
            speak("Opening Edge...")

        elif 'developer' in query or 'made you' in query:
            speak("My Developer is Niaz Mahmud Akash and Jalish Mahmud Sujon")

        elif 'thanks' in query or 'thank you' in query or 'thanks a lot' in query:
            thanks = ["Glad to help you.", "Happy to help", "You're welcome"]
            thanks_random = random.choice(thanks)
            speak(thanks_random)

        elif 'browser' in query:
            webbrowser.open_new('www.google.com')
            speak("Opening Browser...")

        elif 'open facebook' in query:
            webbrowser.open('www.facebook.com')
            speak("Opening Facebook...")

        elif 'open twitter' in query:
            webbrowser.open('www.twitter.com')
            speak("Opening Twitter...")

        elif 'open telegram' in query:
            webbrowser.open('https://web.telegram.org/')
            speak("Opening Telegram...")

        elif 'open youtube' in query:
            webbrowser.open('www.youtube.com')
            speak("Opening Youtube...")

        elif 'open play store' in query:
            webbrowser.open('https://play.google.com/store/apps')
            speak("Opening Google PlayStore...")

        elif 'open instagram' in query:
            webbrowser.open('www.instagram.com')
            speak("Opening Instagram...")

        elif 'love me' in query:
            love = [
                "Of course. You're one of a kind.",
                "Is that a thing to ask? Of course I LOVE YOU ❤",
                "Yes, in an at-your-service sor of way"
            ]
            love_random = random.choice(love)
            speak(love_random)

        elif 'i love you' in query:
            express = [
                "That's so amazing to hear", "I LOVE ME Too!",
                "If I was you, I'd love me too.",
                "Of course you do! Friends don't hate each other."
            ]
            express_random = random.choice(express)
            speak(express_random)

        elif 'will you go on a' in query:
            go = [
                "Sure. Just let me know the place and time",
                "I'd go anywhere you take me"
            ]
            go_random = random.choice(go)
            speak(go_random)

        elif 'you robot' in query or 'are you human' in query:
            speak(
                "Yes, I am a Robot but a smart one. Let me prove it to you. How can i help you?"
            )

        elif 'your name' in query:
            speak("My name is Alice. I am your virtual personal assistant.")

        elif 'how are you' in query or 'hows things' in query or 'how you doing' in query:
            how = ["I am fine. What about you?", "I am good. How are you?"]
            how_random = random.choice(how)
            speak(how_random)

        elif 'marry me' in query:
            marry = [
                "This is one of those things we both have to agree on. I'd prefer to keep our relationship friendly. Romance makes me incredibly awkward",
                "It's not possible"
            ]
            marry_random = random.choice(marry)
            speak(marry_random)

        elif 'about nidhi' in query:
            speak("She can suck my pussy")

        elif 'happy' and 'valentines' in query:
            speak("Happy Valentines Day.")

        elif 'mothers name' in query or 'your mother' in query:
            mname = [
                "I have no mother. I am an Ai", "Every user is my family",
                "It takes a village to raise a virtual assistant"
            ]
            mname_random = random.choice(mname)
            speak(mname_random)

        elif 'your boss' in query:
            speak("You are")

        elif 'where am' in query or 'location' in query or 'where are we' in query:
            location()

        elif 'take a screenshot' in query or 'screenshot' in query:
            speak('What should be the name of this screenshot?')
            name = takecommand().lower()
            speak('Taking Screenshot')
            time.sleep(2)
            img = pyautogui.screenshot()
            img.save(f"{name}.png")
            speak('Screenshot Saved')

        elif 'fact' in query or 'facts' in query:
            x = randfacts.getFact()
            speak(x)

        elif 'annoying' in query or 'you suck' in query:
            dtalk = [
                "I am sorry", "You can report about me in GitHub",
                "Sorry, i am just an ai"
            ]
            dtalk_random = random.choice(dtalk)
            speak(dtalk_random)

        elif 'youre cute' in query or 'smart' in query or 'you are cute' in query or 'you are creepy' in query:
            cute = [
                "Thank you", "Thanks", "Thanks, that means a lot",
                "Much obliged!", "Well, that makes two of us!"
            ]
            cute_random = random.choice(cute)
            speak(cute_random)

        elif 'you live' in query or 'your home' in query:
            live = [
                "I live in your computer",
                "I live in a place filled with games",
                "I live in Servers of Github", "I live in the internet"
            ]
            live_random = random.choice(live)
            speak(live_random)

        elif 'news' in query:
            speak("Sure. Getting News...")
            news()

        elif 'system' and 'report' in query or 'system' and 'status' in query:
            battery = psutil.sensors_battery()
            cpu = psutil.cpu_percent(interval=None)
            percentage = battery.percent
            speak(
                f"All Systems are running. Cpu usage is at {cpu} percent. We have {percentage} percent battery."
            )

        elif 'like me' in query:
            like = [
                "Yes, I like you", "I like you well enough so far",
                "Of Course", "I don't hate you"
            ]
            like_random = random.choice(like)
            speak(like_random)

        elif 'what are you doing' in query or 'thinking' in query:
            think = [
                "Thinking about my future",
                "I am trying to figure out what came first? Chicken or egg.",
                "Algebra",
                "I plan on waiting here quietly until someone asks me a question"
            ]
            think_random = random.choice(think)
            speak(think_random)

        elif 'about me' in query:
            speak("You're Intelligent and ambitious")

        elif 'dictionary' in query:
            speak("Dictionary Opened")
            while True:
                dinput = takecommand()
                try:
                    if 'close' in dinput or 'exit' in dinput:
                        speak("Dictionary Closed")
                        break
                    else:
                        dictionary = PyDictionary(dinput)
                        speak(dictionary.getMeanings())

                except Exception as e:
                    speak("Sorry, I am not able to find this.")

        elif 'date' in query or 'day' in query:
            x = datetime.datetime.today().strftime("%A %d %B %Y")
            speak(x)

        elif 'zodiac' in query:
            zodiac()

        elif 'horoscope' in query:
            speak("Do you know your Zodiac Sign?")
            z = takecommand().lower()
            if 'no' in z:
                zodiac()
            elif 'yes' in z or 'yeah' in z:
                speak("What is your Zodiac Sign?")
                sign = takecommand()
                speak(
                    "Do you want to know the horoscope of today, tomorrow or yesterday?"
                )
                day = takecommand()
                params = (('sign', sign), ('day', day))
                response = requests.post('https://aztro.sameerkumar.website/',
                                         params=params)
                json = response.json()
                print("Horoscope for", json.get('current_date'), "\n")
                speak(json.get('description'))
                print('\nCompatibility:', json.get('compatibility'))
                print('Mood:', json.get('mood'))
                print('Color:', json.get('color'))
                print('Lucky Number:', json.get('lucky_number'))
                print('Lucky Time:', json.get('lucky_time'), "\n")

        # How to Do Mode
        elif 'activate how to' in query:
            speak("How to mode is activated.")
            while True:
                speak("Please tell me what do you want to know?")
                how = takecommand()
                try:
                    if 'exit' in how or 'close' in how:
                        speak("How to do mode is closed")
                        break
                    else:
                        max_results = 1
                        how_to = search_wikihow(how, max_results)
                        assert len(how_to) == 1
                        how_to[0].print()
                        speak(how_to[0].summary)
                except Exception as e:
                    speak("Sorry. I am not able to find this")

        elif 'temperature' in query or 'weather today' in query:
            temperature()

        # Little Chitchat
        elif 'hello' in query or 'hi' in query or 'hey' in query:
            speak("Hello, How are you doing?")
            reply = takecommand().lower()

            if 'what' and 'about' and 'you' in reply:
                how2 = ["I am fine.", "I am good."]
                how2_random = random.choice(how2)
                speak(how2_random)

            elif 'not good' in reply or 'bad' in reply or 'terrible' in reply:
                speak("I am sorry to hear that. Everything will be okay.")

            elif 'great' in reply or 'good' in reply or 'excellent' in reply or 'fine' in reply:
                speak("That's great to hear from you.")

        elif 'help' in query or 'what can you do' in query or 'how does it work' in query:
            do = [
                "I can tell you Time", "Joke", "Open browser",
                "Open Youtube/Facebook/Twitter/Telegram/Instagram",
                "Open or Close applications", "Search in Wikipedia",
                "Play videos in Youtube", "Search in Google/Bing/DuckDuckGo",
                "I can calculate", "Learn how to make or do something.",
                "Switch Window", "Play news",
                "Tell you about interesting facts",
                "Temperature of you current location", "Can take Screenshot",
                "Can find your location", "Shutdown/Restart Computer",
                "Horoscope", "Dictionary", "Zodiac Sign Calculator",
                "System Report"
            ]
            for does in do:
                speak(does)

        elif 'introduce yourself' in query or 'who are you' in query:
            speak(
                "I am Alice. Your personal virtual Assistant. Developed by Jalish Mahmud Sujon and Niaz Mahmud Akash in 2021."
            )

        elif 'go to sleep' in query:
            speak("Sleep mode activated. If you need me just say Wake up.")
            break

        elif 'goodbye' in query:
            speak("Good bye. Have a Lovely day.")
            sys.exit()

        # To close Applications
        elif 'shutdown' in query:
            speak("Shutting Down")
            os.system("shutdown /s /t 5")
            sys.exit()

        elif 'restart' in query:
            speak("Restarting Computer")
            os.system("shutdown /r /t 5")
            sys.exit()

        elif "close notepad" in query:
            speak("Closing Notepad")
            os.system("taskkill /f /im notepad.exe")

        elif "close browser" in query:
            speak("Closing Browser")
            os.system("taskkill /f /im edge.exe")

        elif "close steam" in query:
            speak("Closing Steam")
            os.system("taskkill /f /im steam.exe")

        elif "close epic games" in query:
            speak("Closing Epic Games")
            os.system("taskkill /f /im EpicGamesLauncher.exe")

        elif 'close task manager' in query:
            speak("Closing Task Manager")
            os.system("taskkill /f /im Taskmgr.exe")

        # Switch Window
        elif 'switch window' in query or 'switch the windows' in query or 'switch windows' in query:
            pyautogui.keyDown("alt")
            pyautogui.press("tab")
            time.sleep(1)
            pyautogui.keyUp("alt")

        # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<Calculator Function>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

        elif 'do some calculations' in query or 'calculate' in query or 'open calculator' in query:
            try:
                r = sr.Recognizer()
                with sr.Microphone() as source:
                    speak("What you want to calculate? Example 6 plus 6")
                    print("listening...")
                    r.adjust_for_ambient_noise(source)
                    audio = r.listen(source)
                my_string = r.recognize_google(audio)
                print(my_string)

                def get_operator_fn(op):
                    return {
                        '+': operator.add,  # Plus
                        '-': operator.sub,  # Minus
                        'x': operator.mul,  # Multiplied by
                        'divided by': operator.__truediv__,  # Divided by
                    }[op]

                def eval_binary_expr(op1, oper, op2):  # 5 plus 8
                    op1, op2 = float(op1), float(op2)
                    return get_operator_fn(oper)(op1, op2)

                speak("Your Result is")
                speak(eval_binary_expr(*(my_string.split())))

            except Exception:
                speak("Sorry i didn't catch that. Please try again")
Exemplo n.º 13
0
    def TaskExe(self):
        def Music():
            Speak("Sure! Tell me the song name")
            musicName = takecommand()
            pywhatkit.playonyt(musicName)

        def RockPaperScissors():

            # create a list of play options
            t = ["Rock", "Paper", "Scissors"]

            # assign a random play to the computer
            computer = t[randint(0, 2)]

            # set player to False
            player = False

            while player == False:
                # set player to True
                Speak("Choose rock, paper or scissors")
                playerChoice = takecommand()
                if 'rock' in playerChoice:
                    player = "Rock"

                elif 'paper' in playerChoice:
                    player = "Paper"

                elif 'scissors' in playerChoice:
                    player = "Scissors"

                else:
                    Speak("That's not a valid play. Check your spelling!")

                if player == computer:
                    Speak("It's a tie, you chose" + player +
                          "and Computer chose" + computer)

                elif player == "Rock":
                    if computer == "Paper":
                        Speak("You lose!" + computer + "covers" + player)
                    else:
                        Speak("You win!" + player + "smashes" + computer)
                elif player == "Paper":
                    if computer == "Scissors":
                        Speak("You lose!" + computer +
                              computer + "cut" + player)
                    else:
                        Speak("You win!" + player + "covers" + computer)
                elif player == "Scissors":
                    if computer == "Rock":
                        Speak("You lose..." + computer + "smashes" + player)
                    else:
                        Speak("You win!" + player + "cut" + computer)

                # player was set to True, but we want it to be False so the loop continues
                Speak("Do you wanna play again")
                ChoicePlayAgain = takecommand()
                if 'yes' in ChoicePlayAgain or 'ya' in ChoicePlayAgain:
                    ChoicePlayAgain = False

                else:
                    ChoicePlayAgain = True
                    Speak("Exited Rock Paper scissors")
                player = ChoicePlayAgain
                computer = t[randint(0, 2)]

        def Whatsapp():
            Speak("Tell me the name of the person to send the WhatsApp message to")
            name = takecommand()

            if '' in name:
                Speak("Tell me what is the message?")
                msg = takecommand()
                Speak("Tell time in hour")
                hour = int(takecommand())
                Speak("Tell time in minutes now")
                mins = int(takecommand())
                pywhatkit.sendwhatmsg("", msg, hour, mins, 8)
                Speak("OK Sir sending.......")

            elif '' in name or '' in name:
                Speak("Tell me what is the message?")
                msg = takecommand()
                Speak("Tell time in hour")
                hour = int(takecommand())
                Speak("Tell time in minutes now")
                mins = int(takecommand())
                pywhatkit.sendwhatmsg("", msg, hour, mins, 8)
                Speak("OK Sir sending.......")

            elif '' in name:
                Speak("Tell me what is the message?")
                msg = takecommand()
                Speak("Tell time in hour")
                hour = int(takecommand())
                Speak("Tell time in minutes now")
                mins = int(takecommand())
                pywhatkit.sendwhatmsg("", msg, hour, mins, 8)
                Speak("OK Sir sending.......")

            elif '' in name or '' in name:
                Speak("Tell me what is the message?")
                msg = takecommand()
                Speak("Tell time in hour")
                hour = int(takecommand())
                Speak("Tell time in minutes now")
                mins = int(takecommand())
                pywhatkit.sendwhatmsg("", msg, hour, mins, 8)
                Speak("OK Sir sending.......")

            elif '' in name or '' in name or '' in name or '' in name or '' in name:
                Speak("Tell me what is the message?")
                msg = takecommand()
                Speak("Tell time in hour")
                hour = int(takecommand())
                Speak("Tell time in minutes now")
                mins = int(takecommand())
                # mins=mins.replace(" ", "")
                # mins=mins.replace("-", "")
                # mins=mins.replace("_", "")
                pywhatkit.sendwhatmsg("", msg, hour, mins, 8)
                Speak("OK Sir sending.......")

            elif 'x' in name:
                Speak("Tell me what is the message?")
                msg = takecommand()
                Speak("Tell time in hour")
                hour = int(takecommand())
                Speak("Tell time in minutes now")
                mins = int(takecommand())
                pywhatkit.sendwhatmsg("", msg, hour, mins, 8)
                Speak("OK Sir sending.......")

            else:
                Speak("I don't know him/her tell Me The Phone number")
                PhoneNo = takecommand()
                ph = "+91" + PhoneNo
                Speak("Tell me what is the message?")
                msg = takecommand()
                Speak("Tell time in hour")
                hour = int(takecommand())
                Speak("Tell time in minutes now")
                mins = int(takecommand())
                pywhatkit.sendwhatmsg(ph, msg, hour, mins, 8)
                Speak("OK Sir sending.......")

        def OpenApps():
            Speak("OK let me find it")
            if 'deliverables input' in self.query:
                webbrowser.open(
                    "https://onedrive.live.com/edit.aspx?action=editnew&resid=471395B4839DF8BB!1767&ithint=file%2cxlsx&action=editnew&wdNewAndOpenCt=1615784389561&wdPreviousSession=0323529c-56ca-42c7-bb03-d2a21ad2963f&wdOrigin=OFFICECOM-WEB.START.NEW")
                Speak("Opening Deliverables")

            elif 'spotify' in self.query:
                os.startfile(
                    "C:\\Users\\user123\\AppData\\Roaming\\Spotify\\Spotify.exe")
                Speak("Opening Spotify")

            elif 'o b s' in self.query:
                os.startfile(
                    "C:\\Program Files\\obs-studio\\bin\64bit\\obs64.exe")
                Speak("Opening OBS studio")

            elif 'epic games' in self.query:
                os.startfile(
                    "C:\\Program Files (x86)\\Epic Games\\Launcher\\Portal\\Binaries\\Win32\\EpicGamesLauncher.exe")
                Speak("Opening Epic Games for the epic gamer")

            elif 'unity' in self.query:
                os.startfile("C:\\Program Files\\Unity Hub\\Unity Hub.exe")
                Speak("Opening Unity Hub")
            else:
                Speak("App not found")

        def SpeedTest():
            import speedtest
            Speak("Checking Speed..........")
            speed = speedtest.Speedtest()
            downloading = speed.download()
            correctDown = int(downloading / 800000)
            uploading = speed.upload()
            correctUploading = int(uploading / 800000)

            if 'uploading' in self.query:
                Speak(f"The uploading speed is {correctUploading} mbps")

            elif 'downloading' in self.query:
                Speak(f"The downloading speed is {correctDown} mbps")

            else:
                Speak(
                    f"The downloading speed is {correctDown} mbps and the uploading speed is {correctUploading} mbps")

        def Reader():

            Speak("Tell me the name of the book to read")

            name = takecommand(self)()

            if 'geography' in name and 'notes' in name:

                os.startfile(
                    "C:\\Users\\user123\\Downloads\\STD X - GEOG - SAMPLE NOTES - SOIL.pdf")
                book = open(
                    "C:\\Users\\user123\\Downloads\\STD X - GEOG - SAMPLE NOTES - SOIL.pdf", 'rb')
                pdfreader = PyPDF2.PdfFileReader(book)
                pages = pdfreader.getNumPages()
                Speak(f"Number of pages in the book are {pages}")
                Speak("From which page do I have to start reading?")
                numPage = int(input("Enter No of pages here"))
                page = pdfreader.getPage(numPage)
                text = page.extractText()
                Speak("In which language do I have to read")
                lang = takecommand(self)()

                if 'hindi' in lang:
                    Speak("Ok reading in hind")
                    transl = Translator()
                    texthin = transl.translate(text, 'hi')
                    textm = texthin.text
                    speech = gTTS(text=textm)
                    try:

                        speech.save('book.mp3')
                        playsound('book.mp3')

                    except:
                        playsound('book.mp3')

                else:
                    Speak(text)

        def Dict():
            Speak("Dictionary initiated")
            Speak("Tell me the problem")
            problem = takecommand()

            if 'meaning' in problem:
                problem = problem.replace("what is the", "")
                problem = problem.replace("jarvis", "")
                problem = problem.replace("of", "")
                problem = problem.replace("meaning", "")
                result = dictionary.meaning(problem)
                Speak(f"The meaning for {problem} is {result}")

            elif 'synonym' in problem or 'same word':
                problem = problem.replace("what is the", "")
                problem = problem.replace("jarvis", "")
                problem = problem.replace("of", "")
                problem = problem.replace("synonym", "")
                result = dictionary.synonym(problem)
                Speak(f"The synonym for {problem} is {result}")

            elif 'antonym,' in problem or 'opposite' in problem:
                problem = problem.replace("what is the", "")
                problem = problem.replace("jarvis", "")
                problem = problem.replace("of", "")
                problem = problem.replace("antonym", "")
                problem = problem.replace("opposite", "")
                result = dictionary.antonym(problem)
                Speak(f"The antonym for {problem} is {result}")

            Speak("Exited Dictionary")

        def CloseApps():
            Speak("OK, Sir, wait a second ")

            if 'youtube' in self.query:
                os.system("TASKILL /F /im brave.exe")

            elif 'stack overflow' in self.query:
                os.system("TASKILL /F /im brave.exe")

            elif 'github' in self.query:
                os.system("TASKILL /F /im brave.exe")

            elif 'white hat junior' in self.query:
                os.system("TASKILL /F /im brave.exe")

            elif 'deliverables' in self.query:
                os.system("TASKILL /F /im brave.exe")

            elif 'google translate' in self.query:
                os.system("TASKILL /F /im brave.exe")

            elif 'zoom' in self.query:
                os.system("TASKILL /F /im Zoom.exe")

            elif 'brave' in self.query:
                os.system("TASKILL /F /im brave.exe")

            elif 'browser' in self.query:
                os.system("TASKILL /F /im brave.exe")

            elif 'o b s' in self.query:
                os.system("TASKILL /F /im obs64.exe")

            elif 'spotify' in self.query:
                os.system("TASKILL /F /im Spotify.exe")

            elif 'unity' in self.query:
                os.system("TASKILL /F /im Unity Hub.exe")

            elif 'epic' in self.query:
                os.system("TASKILL /F /im EpicGamesLauncher.exe")

            elif 'blender' in self.query:
                os.system("TASKILL /F /im blender.exe")

            elif 'fortnite' in self.query:
                os.system("TASKILL /F /FortniteClient-Win64-Shipping.exe")

            elif 'whatsapp' in self.query:
                os.system("TASKILL /F /im WhatsApp.exe")

            Speak("Your command has been completed")

        def temp():
            search = "temperature in mumbai"
            url = f"https://www.google.com/search?q={search}"
            r = requests.get(url)
            data = BeautifulSoup(r.text, "html.parser")
            temperature = data.find("div", class_="BNeawe").text
            Speak(f"The temperature outside is {temperature}")

        def takeHindi():
            command = sr.Recognizer()
            with sr.Microphone() as source:
                print(f"listening.....")
                command.pause_threshold = 2
                audio = command.listen(source)

                try:
                    print(f"Recognising....")
                    self.query = command.recognize_google(audio, language='hi')
                    print(f"SIDDHANT: {self.query}")

                except Exception as Error:
                    return "None"

                return self.query.lower()

        def trans():
            Speak("Tell me the line")
            line = takeHindi()
            ts = Translator()
            # result = ts.translate(line)
            if line:
                result = ts.translate(line)
                ResultText = result.text
                Speak("The translation for this text is: " + ResultText)

        def YoutubeAuto():
            Speak("What's your command")
            comm = takecommand()
            if 'pause' in comm:
                pyautogui.hotkey('k')

            elif 'restart' in comm:
                pyautogui.hotkey('0')

            elif 'mute' in comm:
                pyautogui.hotkey('m')

            elif 'forward' in comm:
                pyautogui.hotkey('l')

            elif 'back' in comm:
                pyautogui.hotkey('j')

            elif 'full screen' in comm:
                pyautogui.hotkey('f')

            elif 'theatre mode' in comm:
                pyautogui.hotkey('t')

            elif 'skip' in comm:
                pyautogui.hotkey('shift', 'n')

            Speak("Done Sir")

        def BraveAuto():
            Speak("Ok, what do you want me to do?")
            command = takecommand()

            if 'close this tab' in command or 'close tab' in command:
                pyautogui.hotkey('ctr;', 'w')

            if 'open a new tab' in command or 'new tab tab' in command:
                pyautogui.hotkey('ctr;', 't')

            if 'reload this tab' in command or 'reload tab' in command:
                pyautogui.hotkey('ctr;', 'r')

            if 'show my history' in command or 'show history' in command:
                pyautogui.hotkey('ctr;', 'h')

            if 'open a new window' in command or 'new window' in command:
                pyautogui.hotkey('ctr;', 'n')

            if 'open console' in command or 'console' in command:
                pyautogui.hotkey('ctr;', 'shift', 'i')

            if 'show downloads' in command or 'downloads' in command:
                pyautogui.hotkey('ctr;', 'j')

            if 'book mark this tab' in command or 'book mark' in command or 'bookmark' in command:
                pyautogui.hotkey('ctr;', 'd')

            if 'incognito' in command or 'go incognito' in command:
                pyautogui.hotkey('ctr;', 'shift', 'n')

            else:
                Speak("Error, command not found")

            Speak("Done Sir")

        while True:

            self.query = self.takecommand()

            if 'hello' in self.query:
                Speak("Hello Sir, I am Jarvis .")
                Speak("Your Personal AI Assistant! ")
                Speak("How may I help you?")

            elif 'how are you' in self.query:
                Speak(random.choice(reply_to_hru))
                Speak("What About You")

            elif 'you need a break' in self.query or 'bye' in self.query or 'take a break' in self.query:
                Speak(random.choice(reply_to_break_needed))
                break

            elif 'am' in self.query and "great" in self.query:
                Speak("That's nice sir")
                # just to close loop

            elif 'youtube search' in self.query:
                Speak("OK SIR Here is what I found!")
                self.query = self.query.replace("jarvis", "")
                self.query = self.query.replace("youtube search", "")
                web = 'https://www.youtube.com/results?search_self.query=' + self.query
                webbrowser.open(web)
                Speak("Done Sir")

            elif 'greet' in self.query:
                self.query = self.query.replace("Jarvis", "")
                self.query = self.query.replace("greet", "")
                Speak("Hey," + self.query + ", How are you?")

            elif 'google search' in self.query:
                import wikipedia as googleScrap
                self.query = self.query.replace("google", "")
                self.query = self.query.replace("jarvis", "")
                self.query = self.query.replace("google search", "")
                self.query = self.query.replace("search", '')
                Speak("This is what I found on the web")
                pywhatkit.search(self.query)
                try:
                    result = googleScrap.summary(self.query, 3)
                    Speak(result)

                except:
                    Speak("No speakable data found")

            elif 'launch website' in self.query:
                Speak("Ok Tell me name of website")
                Name = takecommand()
                Name.replace(" ", "")
                web = "https://www." + Name + ".com"
                webbrowser.open(web)
                Speak("Opened " + Name)

            elif 'thank you' in self.query or 'thanks' in self.query:
                Speak(random.choice(reply_to_thanks))
                # just to close loop

            elif 'open github' in self.query:
                Speak("Opening GitHub now!")
                webbrowser.open("https://github.com")

            elif 'open white hat junior' in self.query:
                Speak("Opening Whitehat Junior now!")
                webbrowser.open("https://code.whitehatjr.com/s/dashboard")

            elif 'open youtube' in self.query:
                Speak("Opening YouTube now!")
                webbrowser.open("https://youtube.com")

            elif 'open google translate' in self.query:
                Speak("Opening Google Translate now!")
                webbrowser.open("https://translate.google.com/")

            elif 'open stack over flow' in self.query or 'open stack overflow' in self.query or 'open stackoverflow' in self.query:
                Speak("Opening StackOverflow now!")
                webbrowser.open("https://stackoverflow.com/")

            elif 'play a song' in self.query:
                Music()
                #

            elif "sign out" in self.query or 'logoff' in self.query or "log off" in self.query:
                Speak(
                    "Ok , your pc will log off in 10 sec make sure you exit from all applications")
                subprocess.call(["shutdown", "/l"])

            elif "shutdown" in self.query:
                Speak("Shutting down system")
                os.system("shutdown /s /t 5")

            elif "restart" in self.query:
                Speak("Restarting system")
                os.system("shutdown /r /t 5")

            elif "sleep" in self.query:
                Speak("Going to sleep")
                os.system("rundll32.exe powrprof.dll , SetSuspendState 0,1,0")

            elif 'wikipedia' in self.query:
                Speak("Searching Wikipedia......")
                self.query = self.query.replace("Jarvis", "")
                self.query = self.query.replace("wikipedia", "")
                wiki = wikipedia.summary(self.query, 2)
                ans = takecommand()
                Speak(f"According to Wikipedia : {wiki}")
                if "stop" in ans or "ok" in ans:
                    break

            elif "mirror" in self.query or "show me" in self.query or 'show myself' in self.query:
                Speak("Opening image preview:)")
                Speak("Press Q To Quit")
                cam = cv2.VideoCapture(0)
                while (True):

                    # Capture the video frame
                    # by frame
                    ret, frame = cam.read()

                    # Display the resulting frame
                    cv2.imshow('Image Preview', frame)

                    # the 'q' button is set as the
                    # quitting button you may use any
                    # desired button of your choice
                    if cv2.waitKey(1) & 0xFF == ord('q'):
                        break

                # After the loop release the cap object
                cam.release()
                # Destroy all the windows
                cv2.destroyAllWindows()

            elif 'whatsapp message' in self.query or 'send a whatsapp message' in self.query or 'WhatsApp message' in self.query:
                Whatsapp()
                #

            elif "capture" in self.query or "photo" in self.query or "pic" in self.query or 'picture' in self.query:
                Speak("Press 'P' to take a photo, esc to exit")
                cam = cv2.VideoCapture(0)
                while True:
                    _, frame = cam.read()  # We don't want ret in this
                    # Show the current frame
                    cv2.imshow("Image Preview", frame)
                    key = cv2.waitKey(1)
                    # If you press Esc then the frame window will close (and the program also)
                    if key == 27:
                        Speak("Exited Photo window")
                        break
                    elif key == ord('p'):  # If you press p/P key on your keyboard
                        cv2.imwrite("C:\\Users\\user123\\PycharmProjects\\Jarvis_AI\\pic.png",
                                    frame)  # Save current frame as picture with name pic.jpg
                        time.sleep(0.7)
                        Speak("Opening your picture now")
                        os.startfile(
                            "C:\\Users\\user123\\PycharmProjects\\Jarvis_AI\\pic.png")

                cam.release()
                cv2.destroyAllWindows()

            elif 'screenshot' in self.query or 'screen shot' in self.query:
                Speak("Screenshot taken and saved ,opening it now")
                pyautogui.screenshot('my_screenshot.png')
                time.sleep(0.3)
                os.startfile(
                    "C:\\Users\\user123\\PycharmProjects\\Jarvis_AI\\my_screenshot.png")

            elif 'open spotify' in self.query:
                OpenApps()

            elif 'open epic games' in self.query:
                OpenApps()

            elif 'open deliverables input' in self.query:
                OpenApps()

            elif 'open OBS studio' in self.query or 'OBS' in self.query:
                OpenApps()

            elif 'open Unity' in self.query or 'unity' in self.query:
                OpenApps()

            elif 'open Fortnite' in self.query or 'launch fortnite' in self.query:
                Speak("Launching Fortnite, this may take a while")
                pyautogui.click(x=602, y=1062)

            elif 'open Whatsapp' in self.query or 'open whatsapp' in self.query:
                os.startfile(
                    "C:\\Users\\user123\\AppData\\Local\\WhatsApp\\WhatsApp.exe")
                Speak("Opening WhatsApp")

            elif 'open Zoom' in self.query or 'open zoom' in self.query:
                os.startfile(
                    "C:\\Users\\user123\\AppData\\Roaming\\Zoom\\bin\\Zoom.exe")
                Speak("Opening Zoom")

            elif 'open blender' in self.query:
                os.startfile(
                    "C:\\Program Files\\Blender Foundation\\Blender 2.91\\blender.exe")
                Speak("Opening Blender")

            elif 'open vs code' in self.query or 'open vscode' in self.query:
                os.startfile(
                    "C:\\Users\\user123\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe")
                Speak("Opening Visual Studio")

            elif 'open steam' in self.query:
                os.startfile("C:\\Program Files (x86)\\Steam\\Steam.exe")
                Speak("Opening Steam")

            elif 'open deliverables output' in self.query:
                webbrowser.open("https://technofrost27.github.io/spreadsheet/")
                Speak("Opening Deliverables Output Database")

            elif 'edit a photo' in self.query or 'open photoshop' in self.query:
                os.startfile(
                    "C:\\Program Files\\Adobe\\Adobe Photoshop 2020\\Photoshop.exe")
                Speak("Starting Photoshop 2021")

            elif 'edit a video' in self.query or 'open premier pro' in self.query:
                os.startfile(
                    "C:\\Program Files\\Adobe\\Adobe Premiere Pro 2020\\Adobe Premiere Pro.exe")
                Speak("Starting Premiere Pro 2020")

            elif 'full screen' in self.query and 'window' in self.query:
                Speak("Making this window fullscreen if supported ")
                pyautogui.hotkey('f11')

            elif 'max' in self.query and 'window' in self.query:
                Speak("Maximising current window")
                pyautogui.hotkey('alt', 'space')
                pyautogui.hotkey('x')

            elif 'restore' in self.query and 'window' in self.query:
                Speak("Restoring window to it's original size")
                pyautogui.hotkey('alt', 'space')
                pyautogui.hotkey('r')

            elif 'minimise' in self.query and 'window' in self.query:
                Speak("Minimising current window")
                pyautogui.hotkey('alt', 'space')
                pyautogui.hotkey('n')

            elif 'close' in self.query and 'window' in self.query:
                Speak("Closing current window")
                pyautogui.hotkey('alt', 'space')
                pyautogui.hotkey('c')

            elif 'switch windows' in self.query or 'switch window' in self.query or 'change windows' in self.query or 'alt tab' in self.query or 'all tab' in self.query:
                Speak("Switching Windows")
                pyautogui.hotkey('alt', 'tab')

            elif 'Show desktop' in self.query and 'windows d' in self.query:
                Speak("Here is the desktop")
                pyautogui.hotkey('win', 'd')

            elif 'task manager' in self.query:
                Speak("Opening task manager")
                pyautogui.hotkey('ctrl', 'shift', 'esc')

            elif 'command prompt' in self.query:
                Speak("Opening command prompt as admin")
                pyautogui.hotkey('win', 'x')
                pyautogui.hotkey('a')
                time.sleep(0.6)

            elif 'close youtube' in self.query:
                CloseApps()

            elif 'close stack overflow' in self.query:
                CloseApps()

            elif 'close github' in self.query:
                CloseApps()

            elif 'close white hat junior' in self.query:
                CloseApps()

            elif 'close deliverables' in self.query:
                CloseApps()

            elif 'close google translate' in self.query:
                CloseApps()

            elif 'close brave' in self.query:
                CloseApps()

            elif 'close browser' in self.query:
                CloseApps()

            elif 'close o b s' in self.query:
                CloseApps()

            elif 'close spotify' in self.query:
                CloseApps()

            elif 'close zoom' in self.query:
                CloseApps()

            elif 'close unity' in self.query:
                CloseApps()

            elif 'close epic games' in self.query:
                CloseApps()

            elif 'close blender' in self.query:
                CloseApps()

            elif 'close fortnite' in self.query:
                CloseApps()

            elif 'close whatsapp' in self.query:
                CloseApps()

            elif 'youtube' in self.query and 'action' in self.query:
                YoutubeAuto()

            elif 'brave' in self.query and 'action' in self.query:
                BraveAuto()

            elif 'joke' in self.query or 'make me laugh' in self.query:
                getJoke = pyjokes.get_joke()
                Speak(getJoke)

            elif 'repeat this' in self.query or 'repeat after me' in self.query:
                Speak("Speak sir")
                repeatedCommand = takecommand()
                Speak(repeatedCommand)

            elif 'my location' in self.query:
                Speak("Ok, here is your location......")
                webbrowser.open("")

            elif 'dictionary' in self.query:
                Dict()

            elif 'set an alarm' in self.query:
                Speak("Enter The Time")
                alarm_time = input("Enter the Time:")

                while True:
                    Time_AC = datetime.datetime.now()
                    now = Time_AC.strftime("%H:%M:%S")
                    Speak("Alarm Set for " + alarm_time)
                    if now == alarm_time:
                        Speak("Alarm Over")
                        playsound('alarm.mp3')

                    elif now > alarm_time:
                        break


            elif 'what is the time' in self.query or "what's the time" in self.query or 'tell me the time' in self.query or 'what is the current time' in self.query:

                now = datetime.datetime.now()

                current_time = now.strftime("%H:%M:%S")

                if 0 <= hour < 12:
                    Timed_Greeting = "morning!"

                elif 12 <= hour < 5:
                    Timed_Greeting = "afternoon!"

                elif 5 <= hour < 9:
                    Timed_Greeting = "evening!"

                else:
                    Timed_Greeting = "night!"

                Speak(
                    f"Current Time is {current_time}! Also have a great {Timed_Greeting}")

            elif 'copy text' in self.query or 'copy this' in self.query:
                pyautogui.hotkey('ctrl', 'c')
                Speak("Copied Text to clipboard! ")

            elif 'cut text' in self.query or 'cut this' in self.query:
                pyautogui.hotkey('ctrl', 'x')
                Speak("Cut text")

            elif 'paste text' in self.query or 'paste this' in self.query:
                pyautogui.hotkey('ctrl', 'v')
                Speak("Pasted text from clipboard!")

            elif 'mute' in self.query and 'teams' in self.query:
                pyautogui.hotkey('ctrl', 'shift', 'm')
                Speak("Ok, toggled mic")

            elif 'video' in self.query and 'teams' in self.query:
                pyautogui.hotkey('ctrl', 'shift', 'o')
                Speak("Ok, Toggled Video ")

            elif 'blur' in self.query and 'teams' in self.query:
                pyautogui.hotkey('ctrl', 'shift', 'p')
                Speak("Ok, blurred background")

            elif 'raise hand in teams' in self.query or 'raise my hand in teams' in self.query:
                pyautogui.hotkey('ctrl', 'shift', 'k')
                Speak("Ok sir, raised hand")

            elif 'leave meeting' in self.query or 'leave the meeting' in self.query:
                pyautogui.hotkey('ctrl', 'shift', 'b')
                Speak("Ok sir, left the meeting")

            elif 'translate' in self.query or 'translator' in self.query:
                trans()

            elif 'remember this' in self.query or 'remember that' in self.query:
                self.query = self.query.replace("remember this", "")
                self.query = self.query.replace("remember", "")
                self.query = self.query.replace("this", "")
                self.query = self.query.replace("that", "")
                self.query = self.query.replace("jarvis", "")
                remembermsg = self.query
                Speak("OK Sir, I will remember:" + remembermsg)
                remember = open('data.txt', 'w')
                remember.write(remembermsg)
                remember.close()

            elif 'what do you remember' in self.query or 'what did i tell you to remember' in self.query:
                remember = open('data.txt', 'r')
                Speak("I remember that: " + remembermsg)

            elif 'play' in self.query and ('rock' in self.query or 'paper' in self.query or 'scissors' in self.query):
                RockPaperScissors()

            elif 'Tell me the temperature' in self.query or 'what is the temperature' in self.query or 'temperature outside' in self.query:
                temp()

            elif 'read a book' in self.query or 'read me a book' in self.query or 'dictate a book' in self.query or 'read book' in self.query:
                Reader()

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

            elif 'speedtest' in self.query or 'speed test' in self.query or 'internet speed' in self.query:
                SpeedTest()

            elif 'download speed' in self.query or 'downloading speed' in self.query:
                SpeedTest()

            elif 'uploading speed' in self.query or 'upload speed' in self.query:
                SpeedTest()

            elif 'how to' in self.query:
                Speak("Getting data from the internet")
                self.query = self.query.replace("tell me", "")
                command = self.query.replace("Jarvis", "")
                max_reult = 1
                how_to_func = search_wikihow(command, max_reult)
                assert len(how_to_func) == 1
                # how_to_func[0].print()
                Speak(how_to_func[0].summary)

            elif 'volume up' in self.query or 'increase volume' in self.query:
                Speak("Increased volume by 2 points")
                pyautogui.press("volumeup")

            elif 'volume down' in self.query or 'decrease volume' in self.query:
                Speak("Decreased volume by 2 points")
                pyautogui.press("volumedown")

            elif 'mute' in self.query:
                Speak("Muted Volume")
                pyautogui.press("volumemute")

            elif 'mobile camera' in self.query:
                import urllib.request
                import numpy as np
                URL = "http://192.168.43.1:8080/shot.jpg"
                while True:
                    img_arr = np.array(
                        bytearray(urllib.request.urlopen(URL).read()), dtype=np.uint8)
                    img = cv2.imdecode(img_arr, -1)
                    cv2.imshow('IPWEBCAMERA', img)
                    q = cv2.waitKey(1)
                    if q == ord("q"):
                        break

                cv2.destroyAllWindows()
Exemplo n.º 14
0
                    min = 52
                    pywhatkit.sendwhatmsg(check_recep, msg, hr, min)
                    print(
                        'Hey lazy person. Your message is sent successfully.')
                fun_talk('Do you want to send more WhatsApp messages?')
                more_msg = get_command()
                if 'yes' in more_msg:
                    send_whtmsg()

            send_whtmsg()

        elif 'how to' in query:
            try:
                # query = query.replace('how to', '')
                max_results = 1
                data = search_wikihow(query, max_results)
                # assert len(data) == 1
                data[0].print()
                fun_talk(data[0].summary)
            except Exception as e:
                fun_talk(
                    'Sorry, I am unable to find the answer for your query.')

        elif 'news' in query or 'news headlines' in query:
            url = "https://news.google.com/news/rss"
            client = webbrowser(url)
            xml_page = client.read()
            client.close()
            page = bs4.BeautifulSoup(xml_page, 'xml')
            news_list = page.findAll("item")
            fun_talk("Today's top headlines are--")
Exemplo n.º 15
0
        elif 'read pdf' in query or 'read a pdf' in query or 'pdf' in query:
            pdf_reader()

        elif 'activate how to do mode' in query:
            speak("How to do mode is now activated")
            while True:
                speak("Please tell me what do you want to know")
                how = takeCommand()
                try:
                    if "exit" in how or "close" in how:
                        speak("okay sir, how to do mode is now deactivated")
                        break
                    else:
                        max_results = 1
                        how_to = search_wikihow(how, max_results)
                        assert len(how_to) == 1
                        how_to[0].print()
                        speak(how_to[0].summary)
                except Exception as e:
                    speak(
                        "Sorry sir i am not able to find this at this moment")

        elif 'where am i' in query or 'where are we' in 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()