Exemple #1
0
def run():
    global driver
    driver = webdriver.Chrome('./chromedriver')  # Optional argument, if not specified will search path.
    driver.get("http://www.gmail.com")

    device_id, sample_rate, chunk_size, r = stt.setup()
    '''pytts.play_plain_text("Enter Email Id")
    text = stt.listen(device_id, sample_rate, chunk_size, r, driver, source)
    print(text)'''
    tts.play_plain_text("Please wait while we log you in")
    driver.find_element_by_id("identifierId").send_keys('*****@*****.**')
    driver.find_element_by_id("identifierNext").click()
    time.sleep(2)
    driver.find_element_by_name("password").send_keys('test@12345')
    driver.find_element_by_id("passwordNext").click()
    time.sleep(5)
    driver.find_element_by_class_name('z0').click()
    time.sleep(5)

    with sr.Microphone(device_index = device_id, sample_rate = sample_rate,  
                                chunk_size = chunk_size) as source:
        r.adjust_for_ambient_noise(source)
        r.pause_threshold=1
        tts.play_plain_text("Enter Reciever's Email i d")
        text = stt.listen(device_id, sample_rate, chunk_size, r, driver, source)
    text = text.replace(" ","")
    print(text)

    actions = ActionChains(driver)
    actions.send_keys(text.lower())
    actions.perform()
    webElement = driver.find_element_by_name("subjectbox")

    with sr.Microphone(device_index = device_id, sample_rate = sample_rate,  
                                chunk_size = chunk_size) as source:
        r.adjust_for_ambient_noise(source)
        tts.play_plain_text("Enter Subject")
        subj = stt.listen(device_id, sample_rate, chunk_size, r, driver, source)
    print(subj)

    webElement.send_keys(subj)
    actions = ActionChains(driver)
    webElement.send_keys(Keys.TAB)
    time.sleep(2)
    x=driver.find_element_by_css_selector("div[aria-label='Message Body']")

    with sr.Microphone(device_index = device_id, sample_rate = sample_rate,  
                                chunk_size = chunk_size) as source:
        r.adjust_for_ambient_noise(source)
        tts.play_plain_text("Enter Message")
        msg = stt.listen(device_id, sample_rate, chunk_size, r, driver, source)
    print(msg)

    x.send_keys(msg)
    time.sleep(2)
    sendElem = driver.find_element_by_xpath("//div[text()='Send']")
    sendElem.click()
    time.sleep(2)
    tts.play_plain_text("Mail was sent successfully")
Exemple #2
0
def main_loop():
    threading.Thread(target=get_t).start()
    
    while(True):
        device_id, sample_rate, chunk_size, r = stt.setup()

        with sr.Microphone(device_index = device_id, sample_rate = sample_rate,  
                                        chunk_size = chunk_size) as source:
            r.adjust_for_ambient_noise(source)
            tts.play_plain_text("Hello, What do you want to Do ? Search on Google ?   Search on wikipedia ?   Send a mail ? ")
            text = stt.listen(device_id, sample_rate, chunk_size, r, None, source)
            text = text.lower()
            text = text.strip()

        print(text)
        if "google" in text:
            google.main.run()
        elif "stop" in text or "exit" in text :
            exit(0)
            break
        elif "mail" in text or "gmail" in text:
            mail.run()
        elif "wiki" in text or "wikipedia" in text:
            wiki.run()
Exemple #3
0
import stt
import tts

correctness = 0
total = 0

tts.say("Hi, I am a timepass bot... Talk to me..")

while True:
    tts.say("Say Something..")
    audio = stt.listen()
    text = stt.recognize(audio)
    tts.say("You Said, " + text)
    print("You Said, " + text)
    tts.say("Did I gave you the right Answer ? Say Yes, if I did, else say No")
    audio = stt.listen()
    text = stt.recognize(audio)
    print(text)
    if text.lower() == "yes":
        correctness += 1
    total += 1
    tts.say("Do You wish to test me more ? Say Yes or No")
    audio = stt.listen()
    text = stt.recognize(audio)
    if text.lower() == "no":
        tts.say("For your Information I was " +
                str((correctness * 100) / total) +
                " percent correct. Bye Bye. See You Again")
        break
    else:
        tts.say("I am Happy that you wish to play with me.")
Exemple #4
0
def mainthread(param = ''):
    if(param == ''):
        input = stt.listen()
    else:
        input = param

    #bot commands -start
    if(input == 'exit' or input == 'bye' or input == 'quiet'):
        input = ''
        tts2.speak('goodbye, have a nice day sir!')
        global var
        var = False

    #spotify commands check - start
    elif (input == "open spotify"):
        input = ""
        import spotify
        tts2.speak('spotify opened')   

    elif (input == "play" or input == "pause"):
        input = ""
        try:
            spotify.playPause()
        except NameError:
            tts2.speak(NameErrorSpeak)

    elif (input == "exit spotify" or input == "close spotify"):
        input = ""
        try:
            spotify.close()
        except NameError:
            tts2.speak(NameErrorSpeak)

    elif (input == "mute"):
        input = ""
        try:    
            spotify.mute()
        except NameError:
            tts2.speak(NameErrorSpeak)

    elif (input == "next"):
        input = ""
        try:
            spotify.next()
        except NameError:
            tts2.speak(NameErrorSpeak)

    elif (input == "previous"):
        input = ""
        try:
            spotify.prev()
        except NameError:
            tts2.speak(NameErrorSpeak)

    elif (input == "shuffle"):
        input = ""
        try:
            spotify.shuffle()
        except NameError:
            tts2.speak(NameErrorSpeak)

    elif (input == "repeat"):
        input = ""
        try:
            spotify.repeat()
        except NameError:
            tts2.speak(NameErrorSpeak)

    elif (input == "like"):
        input = ""
        try:
            spotify.like()
        except NameError:
            tts2.speak(NameErrorSpeak)

    elif (input == "what is playing" or input == "what's playing"):
        input = ""
        try:
            spotify.nowPlaying()
        except NameError:
            tts2.speak(NameErrorSpeak)

    elif ('search' in str(input) and 'spotify' in str(input)):
        try:
            stopwords = ['search', 'for', 'spotify', 'on']
            querywords = input.split()
            resultwords  = [word for word in querywords if word.lower() not in stopwords]
            result = ' '.join(resultwords)

            spotify.search(result)
            input = ""
        except NameError:
            tts2.speak(NameErrorSpeak)
        except:
            print("error occured!")

    elif (input == "test method"):
        input = ""
        spotify.search("attention")

    elif (input == "home"):
        input = ""
        try:
            spotify.home()
        except NameError:
            tts2.speak(NameErrorSpeak)

     #spotify commands check -end

    #time and date commands -start
    elif((detectionwords.detectwhat(input) == 'found') and ('time' in str(input))):
        input = ''
        tts2.speak(str(timeFunc.exec('time')))

    elif((detectionwords.detectwhat(input) == 'found') and ('date' in str(input))):
        input = ''
        tts2.speak(str(timeFunc.exec('date')))

    elif((detectionwords.detectwhat(input) == 'found') and ('day' in str(input))):
        input = ''
        tts2.speak(str(timeFunc.exec('day')))

    elif((detectionwords.detectwhat(input) == 'found') and ('month' in str(input))):
        input = ''
        tts2.speak(str(timeFunc.exec('month')))

    elif((detectionwords.detectwhat(input) == 'found') and ('year' in str(input))):
        input = ''
        tts2.speak(str(timeFunc.exec('year')))

    elif((detectionwords.detectwhat(input) == 'found') and ('hour' in str(input))):
        input = ''
        tts2.speak(str(timeFunc.exec('hour')))     
                
    elif((detectionwords.detectwhat(input) == 'found') and (('minute' in str(input)) or ('minutes' in str(input)))):
        input = ''
        tts2.speak(str(timeFunc.exec('minute')))
Exemple #5
0
        tts2.speak(str(timeFunc.exec('month')))

    elif((detectionwords.detectwhat(input) == 'found') and ('year' in str(input))):
        input = ''
        tts2.speak(str(timeFunc.exec('year')))

    elif((detectionwords.detectwhat(input) == 'found') and ('hour' in str(input))):
        input = ''
        tts2.speak(str(timeFunc.exec('hour')))     
                
    elif((detectionwords.detectwhat(input) == 'found') and (('minute' in str(input)) or ('minutes' in str(input)))):
        input = ''
        tts2.speak(str(timeFunc.exec('minute')))

        #time and date commands -end

#wake word detection
while 1:
    wakewordinput = stt.listen()
    wakewordlistener = wakeword.wakeworddetect(wakewordinput)

    if(wakewordlistener == 'awake'):
        timeFunc.welcome()

        while var:
            mainthread('')

    else: #wakeword detection else
        continue

Exemple #6
0
def run():
    global driver
    tts.play_plain_text("loading please wait")
    print("bert model loading started")
    model = build_model(configs.squad.squad, download=False)
    print("bert model loaded")
    device_id, sample_rate, chunk_size, r = stt.setup()
    tts.play_plain_text("loading please wait")
    driver = webdriver.Chrome(
        './chromedriver'
    )  # Optional argument, if not specified will search path.
    driver.get('https://www.wikipedia.org/')
    # time.sleep(5) # Let the user actually see something!
    search_box = driver.find_element_by_id("searchInput")
    time.sleep(3)  # Let the user actually see something!
    # text="cricket"
    # # speak(text)
    # search_box.send_keys(text)
    # search_box.submit()
    time.sleep(5)  # Let the user actually see something!
    # driver.execute_script("window.history.go(-1)")
    #time.sleep(3) # Let the user actually see something!

    with sr.Microphone(device_index=device_id,
                       sample_rate=sample_rate,
                       chunk_size=chunk_size) as source:
        r.adjust_for_ambient_noise(source)
        tts.play_plain_text("What do you want to search ?")
        # #main
        text = stt.listen(device_id, sample_rate, chunk_size, r, driver,
                          source)
    # time.sleep(2)
    stt.speak(text)

    # #confirmation from the user
    with sr.Microphone(device_index=device_id,
                       sample_rate=sample_rate,
                       chunk_size=chunk_size) as source:
        r.adjust_for_ambient_noise(source)
        tts.play_plain_text("Are you sure you want to search for " + text)
        resp = stt.listen(device_id, sample_rate, chunk_size, r, driver,
                          source)

    while resp != "yes":
        with sr.Microphone(device_index=device_id,
                           sample_rate=sample_rate,
                           chunk_size=chunk_size) as source:
            r.adjust_for_ambient_noise(source)
            tts.play_plain_text("Repeat your search")
            text = stt.listen(device_id, sample_rate, chunk_size, r, driver,
                              source)
            time.sleep(2)
            stt.speak(text)
            tts.play_plain_text("Are you sure you want to search for " + text)
            resp = stt.listen(device_id, sample_rate, chunk_size, r, driver,
                              source)

    tts.play_plain_text("Searching results")
    search_box.send_keys(text)
    search_box.submit()
    #time.sleep(5) # Let the user actually see something!
    #sdriver.quit()

    while (True):
        with sr.Microphone(device_index=device_id,
                           sample_rate=sample_rate,
                           chunk_size=chunk_size) as source:
            r.adjust_for_ambient_noise(source)
            tts.play_plain_text(
                """Do you want 1. summary or 2. full content or 
            3. start a question answering session""")
            # tts.play_plain_text("start question answering session?")
            resp1 = stt.listen(device_id, sample_rate, chunk_size, r, driver,
                               source)

        if "summary" in resp1 or "one" in resp1 or "1" in resp1:
            article_summary = w.summary(text)
            tts.play_plain_text("Starting summary")
            tts.play_plain_text(article_summary)
            break
        elif "two" in resp1 or "2" in resp1:
            full_content = w.WikipediaPage(text).content
            tts.play_plain_text("Starting full content")
            tts.play_plain_text(full_content)
            break
        elif "three" in resp1 or "3" in resp1 or "tree" in resp1:
            q = "yes"
            while q != "no":
                with sr.Microphone(device_index=device_id,
                                   sample_rate=sample_rate,
                                   chunk_size=chunk_size) as source:
                    r.adjust_for_ambient_noise(source)
                    tts.play_plain_text(
                        "Please utter your question after the beep")
                    q = stt.listen(device_id, sample_rate, chunk_size, r,
                                   driver, source)
                    pred = model([w.summary(text, sentences=10)], [q])
                    pred = pred[0][0]
                    tts.play_plain_text("The best match answer found is " +
                                        pred)

                    tts.play_plain_text("do you have another question ?")
                    q = stt.listen(device_id, sample_rate, chunk_size, r,
                                   driver, source)
                    q = q.strip()
                    q = q.lower()
            break
        else:
            tts.play_plain_text("Invalid option")