Ejemplo n.º 1
0
    def webcam(self): #Webcam Shoot
        
        try:

    
            ec.capture(0,False,f"./logs/webcam{time.time()}.jpg")
        
        
        except Exception: 
            pass
Ejemplo n.º 2
0
    def webcam(self):

        try:

            capt = ec.capture(0, False, f'{time.time()}.jpg')
            self.appendlog(capt)

        except Exception:
            pass
Ejemplo n.º 3
0
def mainfun(reqst):
    if 'wikipedia' in reqst or "search" in reqst or 'wiki' in reqst:
        # am.speak('Searching Wikipedia...')
        statement = reqst.replace("wikipedia", "")
        statement = reqst.replace("search", "")
        statement = reqst.replace("wiki", "")
        results = wikipedia.summary(statement, sentences=3)
        print(results)
        speak("According to Wikipedia")
        speak(results)

    if 'open youtube' in reqst:

        webbrowser.get(
            "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s"
        ).open("https://www.youtube.com")

    elif 'play' in reqst or 'in youtube' in reqst:
        statement = reqst.replace("in youtube", "")
        statement = reqst.replace("play", "")
        webbrowser.get(
            "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s"
        ).open("https://www.youtube.com/results?search_query=" + statement)

    elif 'open google' in reqst:
        webbrowser.get(
            "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s"
        ).open("https://www.google.com")
        speak("Google chrome is open now")

    elif 'open gmail' in reqst:
        webbrowser.get(
            "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s"
        ).open("gmail.com")
        speak("Google Mail open now")

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

    elif "open stackoverflow" in reqst:
        webbrowser.get(
            "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s"
        ).open("https://stackoverflow.com/login")
        speak("Here is stackoverflow")

    elif "take a photo" in reqst:
        ecapture.capture(0, "Anna's camera", "img.jpg")

    elif "log off" in reqst or "sign out" in reqst:
        speak(
            "Ok , your pc will log off in 10 sec make sure you exit from all applications"
        )
        subprocess.call(["shutdown", "/l"])
    elif 'who' in reqst or "what " in reqst or "why" in reqst:
        statement = reqst
        if 'what' in reqst:
            statement = reqst.replace("what", "")
        elif "why" in reqst:
            statement = reqst.replace("why", "")
        elif "who" in reqst:
            statement = reqst.replace("who", "")
        elif 'is' in reqst:
            statement = reqst.replace("is", "")
        elif "are" in reqst:
            statement = reqst.replace("are", "")
        app_id = "E6P6R2-U4Q63L5L2A"
        client = wolframalpha.Client(app_id)
        res = client.query(statement)
        answer = next(res.results).text
        speak(answer)

    else:
        try:
            app_id = "E6P6R2-U4Q63L5L2A"
            client = wolframalpha.Client(app_id)
            res = client.query(reqst)
            answer = next(res.results).text
            speak(answer)
        except:
            speak("Unknown command, please say correctly")
            )
            headlines = headlines.get_headlines(
                "https://timesofindia.indiatimes.com/home/headlines")
            for i in range(15):
                speak(headlines['text'][i])
                command = takeCommand()
                if 'visit' in command:
                    webbrowser.open_new_tab(headlines['link'][i])
                    break
                elif 'stop' in command:
                    break
                time.sleep(5)
            time.sleep(6)

        elif "camera" in statement or "take a photo" in statement:
            ec.capture(0, "robo camera", "img.jpg")

        elif 'search' in statement:
            statement = statement.replace("search", "")
            webbrowser.open_new_tab(statement)
            time.sleep(5)

        elif 'flip the coin' in statement or 'toss the coin' in statement or 'toss a coin' in statement:
            chances = ['Heads', 'Tails']
            coinRes = random.choice(chances)
            picLine = random.randint(1, 3)
            lines = [htLine1, htLine2, htLine3]
            lines[picLine - 1]()

        elif 'dice' in statement:
            num = random.randint(1, 6)