示例#1
0
def start():
    hour = int(datetime.datetime.now().hour)  # 1 to 24 hour give
    if hour >= 0 and hour < 12:
        speak_now.speak("Good Morning sir!")
    elif hour >= 12 and hour < 18:
        speak_now.speak("Good Afternoon sir!")
    else:
        speak_now.speak("Good Evening sir!")
    speak_now.speak("I am JERVIS. How can i help you sir ?")
示例#2
0
def takevoice(data):
    r = sr.Recognizer()
    with sr.Microphone() as source:
        print("Listening......")
        r.energy_threshold = 1000
        r.pause_threshold = 0.8
        audio = r.listen(source)
    try:
        print("Recognizing.....")
        query = r.recognize_google(audio, language='en-in')
        print("User said :", query)
        return query

    except Exception as e:
        if data == 1:
            speak_now.speak("Next news is ")
        return "0"
示例#3
0
def takevoice():
    while True:
        #if alarm_set == 1:
        #alarm_clock.check(set_time, reminder)
        r = sr.Recognizer()
        with sr.Microphone() as source:
            print("Listening......")
            r.energy_threshold = 1000  #please change it as per the noise in your surround from 300 to 1000
            r.pause_threshold = 1  #time duration of one word after anather word
            audio = r.listen(source)

        try:
            print("Recognizing.....")
            query = r.recognize_google(audio, language='en-in')
            print("User said :", query)
            return query

        except Exception as e:
            speak_now.speak("Say that again please....")
示例#4
0
def news_report():
    driver = webdriver.Chrome(
        "C:/Users/sourab/Desktop/jervis/chromedriver.exe")
    driver.get('http://feeds.bbci.co.uk/news/video_and_audio/world/rss.xml')
    speak_now.speak("Today important newses are....")
    for x in range(1, 20):
        news = driver.find_element_by_xpath(
            "/ html / body / div[3] / div[1] / div/div[" + str(x) +
            "]/ul/li/a")
        speak_now.speak(news.text)
        query = takevoice(1).lower()
        query_match = find.matching(query)
        if int(query_match) == 19:
            news.click()
            while (True):
                query = takevoice(0).lower()
                query_match = find.matching(query)
                if int(query_match) == 20:
                    pyautogui.hotkey('Alt', 'left')
                    break
        elif int(query_match) == 21:
            y = x - 1
            news = driver.find_element_by_xpath(
                "/ html / body / div[3] / div[1] / div/div[" + str(y) +
                "]/ul/li/a")
            speak_now.speak(news.text)
            query = takevoice(0).lower()
            query = find.matching(query)
            if int(query_match) == 19:
                news.click()
        elif int(query_match) == 16:
            return
示例#5
0
def whatsapp(name, msg):
    driver = webdriver.Chrome(
        'C:/Users/sourab/Desktop/jervis/chromedriver.exe')
    driver.get('https://web.whatsapp.com/')
    speak_now.speak("Please check that QR code is scanned")
    input("")
    #user = driver.find_element_by_xpath('//span[@title = "{}"]'.format(name))  # for loop before it name in all_name
    user = driver.find_element_by_xpath(
        '/html/body/div[1]/div/div/div[3]/div/div[1]/div/label/input')
    user.send_keys(name)
    time.sleep(1)
    select = driver.find_element_by_xpath(
        '/html/body/div[1]/div/div/div[3]/div/div[2]/div[1]/div/div/div[2]/div/div'
    )
    select.click()
    msg_box = driver.find_element_by_class_name('_13mgZ')
    # for r in range(0,100):
    msg_box.send_keys(msg)
    button = driver.find_element_by_class_name('_3M-N-')
    button.click()
    time.sleep(1)
    return
示例#6
0
def matching(text):
    h_match = 0
    to_be_send = 0
    max = 0
    f = open("data_set.txt", "r")
    for i in f:
        k = i.find(":")
        l = i[0:k]
        matched = fuzz.token_set_ratio(text, l)
        if (h_match < matched):
            h_match = matched
            to_be_send = i[k + 1:]
            sentence = l
            #print(i)
        if (int(i[k + 1:]) > int(max)):
            max = i[k + 1:]

    f.close()
    if (int(h_match) < 70):
        sentence = "Do you want to say" + sentence
        speak_now.speak(sentence)
        query = takevo.takevoice().lower()
        try:
            t = matching(query)
        except:
            speak_now.speak("please say yes or no")
        if int(t) == 17:
            f = open("data_set.txt", "a")
            f.write("{}:{}".format(text, to_be_send))
            f.close()
        elif int(t) == 18:
            f = open("data_set.txt", "a")
            f.write("{}:{}\n".format(text, int(max) + 1))
            f.close()

    return (to_be_send)
示例#7
0
        elif 'rename' in work:
            speak("Which folder do you want to rename ?")
            re_name = takevoice().lower()
            speak("Whats the new folder name ?")
            name = takevoice().lower()
            os.rename(re_name, name)
            speak("Folder name is changed")
        elif 'go back' in work:
            speak("Back to the previous location")
            f_location = os.path.dirname(f_location)
            os.startfile(f_location)


if __name__ == "__main__":
    cam_face.face_matching()
    speak_now.speak("Face matched")
    start()
    while True:
        #if alarm_set == 1:
        #alarm_clock.check(set_time, reminder)
        query = takevo.takevoice().lower()
        query_match = find.matching(query)
        if int(query_match) == 2:
            speak_now.speak("Searching Wikipedia...")
            query = query.replace("wikipedia", "")
            result = wikipedia.summary(query, sentences=2)
            speak_now.speak("According to wikipedia")
            print(result)
            speak_now.speak(result)

        elif 'open youtube' in query:
示例#8
0
def select_speak():
    pyautogui.hotkey('ctrl', 'c')
    win32clipboard.OpenClipboard()
    x = win32clipboard.GetClipboardData()
    win32clipboard.CloseClipboard()
    speak_now.speak(x)