コード例 #1
0
def c_compose():
    #driver = webdriver.Firefox()
    speak.tts('ok, closing compose mail', 'en-us')
    keyboard.press(Key.esc)
    keyboard.release(Key.esc)
    speak.tts('compose closed', 'en-us')
    return
コード例 #2
0
ファイル: domSpeech1.py プロジェクト: dompower/Robo-projects
def main():
    # obtain audio from the microphone
    r = sr.Recognizer()
    with sr.Microphone() as source:
        #os.system('aplay '+ alert)
        print("Say something!")
   
    
        audio = r.listen(source)
        # recognize speech using Google Speech Recognition

    try:
        # for testing purposes, you're just using the default API key
        # to use another API key, use `r.recognize_google(audio,key="GOOGLE_SPEECH_RECOGNITION_API_KEY")`
        # instead of `r.recognize_google(audio)`

        text = r.recognize_google(audio)
        print("Google thinks,  you said... " + text )
        #text = "salaam Alaikum"
        reply_msg1 = RoboResponses.responses(text)
        print("Robo Response : " + reply_msg1)
        #text = 'hello, its a surprise for me'
        speak.tts(reply_msg1,lang)
        
        main()
    

    except sr.UnknownValueError:
        print("Google Speech Recognition could not understand audio")
        main()
    
    except sr.RequestError as e:
        print("Could not request results from Google Speech Recognition service;{0}".format(e))
        main()
コード例 #3
0
def go_b():
    speak.tts('ok', 'en-us')
    gb = driver.find_element_by_xpath(
        "/html/body/div[7]/div[3]/div/div[2]/div[1]/div[2]/div/div/div/div/div[1]/div[2]/div[1]/div/div[1]/div"
    )
    time.sleep(2)
    gb.click()
    return
コード例 #4
0
def compose():
    #driver = webdriver.Firefox()
    speak.tts('ok, clicking on compose', 'en-us')
    #
    add = driver.find_element_by_class_name("z0")
    add.click()
    speak.tts('now you can compose new mail', 'en')
    return
コード例 #5
0
def logout():

    speak.tts('ok,signing out gmail', 'en-us')
    driver.get("https://mail.google.com/mail/?logout")
    time.sleep(1)
    speak.tts('gmail logout,successfull', 'en-us')
    driver.close()
    time.sleep(2)
    return
コード例 #6
0
def delt():

    dlt = driver.find_element_by_xpath(
        "/html/body/div[7]/div[3]/div/div[2]/div[1]/div[2]/div/div/div/div/div[1]/div[2]/div[1]/div/div[2]/div[3]"
    )
    speak.tts('ok, deleting mail', 'en-us')
    time.sleep(2)
    dlt.click()
    speak.tts('mail deleted', 'en-us')
    return
コード例 #7
0
def send():

    msg = driver.find_element_by_css_selector(".Ar.Au")
    msg.click()
    speak.tts('ok , clicking send button', 'en-us')
    keyboard.press(Key.ctrl)
    keyboard.press(Key.enter)
    keyboard.release(Key.ctrl)
    keyboard.release(Key.enter)
    speak.tts('message sent', 'en-us')
    return
コード例 #8
0
def down():

    speak.tts('ok', 'en')
    win32api.SetCursorPos((200, 200))
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 200, 200, 0, 0)
    #driver.maximize_window()
    #move = driver.find_element_by_css_selector(".gb_Xa.gb_dc")
    #time.sleep(2)
    #move.click()
    keyboard.press(Key.down)
    keyboard.release(Key.down)
    return
コード例 #9
0
def read():
    sub = driver.find_element_by_class_name("hP")
    speak.tts("subject, ," + sub.text, "en")
    frm = driver.find_element_by_class_name("gD")
    speak.tts("from, ," + frm.text, "en-us")
    date = driver.find_element_by_class_name("g3")
    speak.tts("recieved,on," + date.text, "en-us")
    msg = driver.find_element_by_css_selector(".ii.gt")
    print('word length ' + str(len(msg.text)))
    if len(msg.text) == 0:
        speak.tts('nothing to read in message section', 'en-us')
    else:
        speak.tts("wait, rio isfetching the message to read", 'en')
        tts1("message," + msg.text, "en-us")
        os.remove('temp1.mp3')
コード例 #10
0
ファイル: readfile.py プロジェクト: SGanesh19/LaTeX-to-Speech
def readfile(path):
    try:
        print("Building text to speech system")
        print("Opening and closing a file.")

        text_file = open(path, "r")
        lines = text_file.readlines()
        print(lines)
        for line in lines:
            lang = 'en'
            tts(line)
        text_file.close()

        print("Process Completed")
    except Exception as e:
        print(e)
def detail_input():
    lang ='hi'
    print("गायक का नाम बताएं")
    speak.tts('गायक का नाम बताएं', lang)
    with sr.Microphone() as source:
        audio = r.listen(source)
    text = r.recognize_google(audio)
    print(text)
    
    singer = text

    print("गाने का नाम बताएं")
    speak.tts('गाने का नाम बताएं', lang)
    with sr.Microphone() as source:
        audio = r.listen(source)
    text = r.recognize_google(audio)
    print(text)
    song = text
    lyrics = get_lyrics(singer,song)
    write_infile(lyrics,singer,song)
    return [singer,song]
def details_input():
    lang = 'en'
    print("Tell me the singer")
    speak.tts('Tell me the singer', lang)
    with sr.Microphone() as source:
        audio = r.listen(source)
    text = r.recognize_google(audio)
    print(text)
    
    singer = text

    print("Tell me the name of the song")
    speak.tts('Tell me the name of the song', lang)
    with sr.Microphone() as source:
        audio = r.listen(source)
    text = r.recognize_google(audio)
    print(text)
    song = text
    lyrics = get_lyrics(singer,song)
    write_infile(lyrics,singer,song)
    return [singer,song]
コード例 #13
0
def subject():
    add = driver.find_element_by_class_name("aoT")
    add.click()
    speak.tts('enter ,subject', 'en-us')
    while True:

        r = sr.Recognizer()
        with sr.Microphone() as source:

            try:
                speak.tts('listening', 'en-us')
                speech = r.listen(source, timeout=2, phrase_time_limit=5)
                text = r.recognize_google(
                    speech, key="AIzaSyBOti4mM-6x9WDnZIjIeyEU21OpBXqWBgw")
                word = text.lower()

                if word == 'done':
                    return
                if word == 'back':
                    keyboard.press(Key.backspace)
                    continue
                if word == 'space':
                    keyboard.press(Key.space)
                    continue
                add = driver.find_element_by_class_name("aoT")
                add.send_keys(word)
                # time.sleep(1)
                #keyboard.press(Key.backspace)
                speak.tts(word + ', ok', 'en')
            except Exception as e:
                pass
コード例 #14
0
def gmail():
    #authentication part:
    speak.tts("verify ,your self", 'en-us')
    uid = fd.fcd()
    with sqlite3.connect("pw.db") as db:
        c = db.cursor()
    c.execute("SELECT mail FROM 'user' WHERE uid = (?);", [uid])
    user_id = c.fetchone()[0]
    c.execute("SELECT password FROM 'user' WHERE uid = (?);", [uid])
    pswd = c.fetchone()[0]
    db.commit()
    db.close()

    speak.tts('signing in gmail', 'en-us')
    #driver = webdriver.Firefox()
    driver.get('https://accounts.google.com/signin')
    time.sleep(2)

    email_id = driver.find_element_by_id("identifierId")
    email_id.send_keys(user_id + Keys.ENTER)
    time.sleep(2)
    pswdi = driver.find_element_by_name('password')
    pswdi.send_keys(pswd + Keys.ENTER)
    time.sleep(2)
    driver.get('https://mail.google.com/mail/#inbox')
    speak.tts('gmail login, successfull', 'en-us')

    return
コード例 #15
0
def command():
    while True:
        r = sr.Recognizer()
        with sr.Microphone() as source:
            speak.tts('give me command', 'en')
            time.sleep(0.10)

            try:
                speech = r.listen(source, timeout=2, phrase_time_limit=2)
                text = r.recognize_google(
                    speech, key="AIzaSyBOti4mM-6x9WDnZIjIeyEU21OpBXqWBgw")
                valid = valid_command.check(text.lower())
                if valid == 0:
                    print("wrong command : " + text.lower())
                    speak.tts(
                        "unrecognised command ," + text + ", please  wait",
                        'en')
                    continue
                else:
                    return text.lower()

            except Exception as e:
                pass
コード例 #16
0
def un():
    unread = driver.find_element_by_css_selector(".J-Ke.n0")
    #speak.tts('you have,'+ unread.text+'unread mails','en-us')
    num = unread.text
    c = num[6:-1]
    speak.tts('you have,' + c + ',unread mails', 'en-us')
    umail = driver.find_element_by_xpath("//*[@class='zF']")
    speak.tts("opening ,unread, mail", 'en-us')
    driver.execute_script("return arguments[0].click();", umail)
    speak.tts("opened ,mail", 'en-us')
コード例 #17
0
def attach():
    speak.tts('ok, clicking on attach', 'en-us')
    unread = driver.find_element_by_css_selector(".wG.J-Z-I")
    unread.click()
    speak.tts('attach window opened', 'en-us')
    win32api.SetCursorPos((180, 200))
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 180, 200, 0, 0)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 180, 200, 0, 0)
    while True:
        r = sr.Recognizer()
        with sr.Microphone() as source:
            try:
                speak.tts('listening', 'en-us')
                speech = r.listen(source, timeout=2, phrase_time_limit=2)
                text = r.recognize_google(
                    speech, key="AIzaSyBOti4mM-6x9WDnZIjIeyEU21OpBXqWBgw")
                word = text.lower()
                if word == 'open':
                    print(word)
                    keyboard.press(Key.enter)
                    keyboard.release(Key.enter)
                    continue
                if word == 'attach':
                    print(word)
                    keyboard.press(Key.enter)
                    keyboard.release(Key.enter)
                    return
                if word == 'down':
                    print(word)
                    keyboard.press(Key.down)
                    keyboard.release(Key.down)
                    continue
                if word == 'aap':
                    print(word)
                    keyboard.press(Key.up)
                    keyboard.release(Key.up)
                    continue
                if word == 'left':
                    print(word)
                    keyboard.press(Key.left)
                    keyboard.release(Key.left)
                    continue
                if word == 'right':
                    print(word)
                    keyboard.press(Key.right)
                    keyboard.release(Key.right)
                    continue
                if word == 'back':
                    keyboard.press(Key.backspace)
                    keyboard.release(Key.backspace)
                    continue
            except Exception as e:
                pass
コード例 #18
0
def search():
    add = driver.find_element_by_class_name("gbqfif")
    add.click()
    speak.tts('ok ,what do you want to search', 'en-us')
    r = sr.Recognizer()
    with sr.Microphone() as source:
        try:
            speak.tts('listening', 'en')
            speech = r.listen(source, timeout=2, phrase_time_limit=5)
            text = r.recognize_google(
                speech, key="AIzaSyBOti4mM-6x9WDnZIjIeyEU21OpBXqWBgw")
            word = text.lower()
            add = driver.find_element_by_class_name("gbqfif")
            add.send_keys(word + Keys.ENTER)
            speak.tts(word + ', search done', 'en-us')
        except Exception as e:
            pass
コード例 #19
0
def msg():
    add = driver.find_element_by_css_selector("div[aria-label='Message Body']")
    add.click()
    speak.tts('dictate, your mail', 'en-us')
    while True:

        r = sr.Recognizer()
        with sr.Microphone() as source:

            try:
                speak.tts('listening', 'en-us')
                speech = r.listen(source, timeout=2, phrase_time_limit=10)
                text = r.recognize_google(
                    speech, key="AIzaSyBOti4mM-6x9WDnZIjIeyEU21OpBXqWBgw")
                word = text.lower()

                if word == 'done':
                    return
                if word in ['back']:
                    keyboard.press(Key.backspace)
                    keyboard.release(Key.backspace)
                    continue
                if word == 'space':
                    keyboard.press(Key.space)
                    keyboard.release(Key.space)
                    continue
                if word == 'newline':
                    keyboard.press(Key.enter)
                    keyboard.release(Key.enter)
                    continue
                if word == 'tab':
                    keyboard.press(Key.tab)
                    keyboard.release(Key.tab)
                add = driver.find_element_by_css_selector(
                    "div[aria-label='Message Body']")
                add.send_keys(word)
                # time.sleep(1)
                #keyboard.press(Key.backspace)
                speak.tts(word + ', ok', 'en-us')
            except Exception as e:
                pass
コード例 #20
0
ファイル: readfile.py プロジェクト: SGanesh19/LaTeX-to-Speech
def readtxt(data):
    try:
        tts(data)
        print("Process Completed")
    except Exception as e:
        print(e)
コード例 #21
0
import speech_recognition as sr
import speak
import requests
from bs4 import BeautifulSoup

r = sr.Recognizer()

with sr.Microphone() as source:
    print('Say Something!')
    audio = r.listen(source)
    print('Done!')

text = r.recognize_google(audio)

url = "https://www.google.com/search?q=" + text

response = requests.get(url)
soup = BeautifulSoup(response.text, "lxml")

for item in soup.select(".r a"):
    print(item.text)
    speak.tts(item.text, "en")
    break
コード例 #22
0
conv = open('chats.txt', 'r').readlines(
)  # 'conv' is a list trainer,.readlines() reading the input and response
#  from this listtrainer
bot.train(
    conv
)  #  bot.train() is a module to train the bot to pass response to user input

print('Friday:Hi I am Friday, Who is on the other side?')

reply1 = str(
    'Hi I am Friday, Who is on the other side?'
)  # here the string statement is stored in reply1 which will be pass through
# speak module for speech conversion
lang = 'en-uk'  # language for the API to reply

speak.tts(reply1, lang)  # text to speech conversion

r = sr.Recognizer(
)  # recognizer module from speech recognition (.Recognizer())
while True:

    with sr.Microphone(
    ) as source:  # Microphone module from pyaudio (.Microphone())

        r.adjust_for_ambient_noise(source)

        audio1 = r.listen(
            source
        )  # recognizing user audio input with r.listen() and storing in audio1
        try:
            name1 = r.recognize_google(
def run():
    translator = Translator()
    r = sr.Recognizer()
    while True:
        with sr.Microphone() as source:
            print('How may I help you?')
            audio = r.listen(source)
        #text = stt.speech()
        text = r.recognize_google(audio)
        tx = translator.translate(text)
        if tx.src == 'en':
            print(tx.text)
            words = (tx.text).split()
            if "email" in words or "mail" in words or "e-mail" in words:
                if "send" in words or "forward" in words:
                    mail1.email()
            elif "open" in words:
                if "calculator" in words:
                    speak.tts('Opening calculator', lang)
                    os.system('calc.exe')
                elif "Notepad" in words:
                    speak.tts('Opening notepad', lang)
                    os.system('notepad.exe')
                elif "Word" in words:
                    speak.tts('Opening word', lang)
                    filepath = "C:\Program Files (x86)\Microsoft Office\root\Office16"
                    os.system('start winword.exe'.format(filepath))
                elif "PowerPoint" in words or "PPT" in words:
                    speak.tts('Opening power point', lang)
                    filepath = "C:\Program Files (x86)\Microsoft Office\root\Office16"
                    os.system('start powerpnt.exe'.format(filepath))
                elif "PDF" in words:
                    speak.tts('Opening PDF', lang)
                    filepath = "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe"
                    os.system('start AcroRd32.exe'.format(filepath))
                elif "onenote" in words:
                    speak.tts('Opening onenote', lang)
                    filepath = "C:\Program Files (x86)\Microsoft Office\root\Office16"
                    os.system('start onenote.exe'.format(filepath))
                elif "Excel" in words:
                    speak.tts('Opening excel', lang)
                    filepath = "C:\Program Files (x86)\Microsoft Office\root\Office16"
                    os.system('start excel.exe'.format(filepath))
            elif "lyrics" in words:
                s = song.details_input()
                print("\r\n")
                F = open(s[0] + "_" + s[1] + ".txt", 'r')
                ly = F.read()
                print(ly)
                F.close()
                os.remove(s[0] + "_" + s[1] + ".txt")
            else:
                try:
                    app_id = "3WPY8L-LUUR9EVXXK"
                    client = wolframalpha.Client(app_id)
                    res = client.query(tx.text)
                    answer = next(res.results).text
                    print(answer)
                except:
                    print(wikipedia.summary(tx.text, sentences=2))
        else:
            text = r.recognize_google(audio, language='hi')
            print(text)
            lang = 'hi'
            words = text.split()
            if "भेजो" in words or "भेजना" in words or "भेजिए" in words or "भेज" in words:
                if "ईमेल" in words or "मेल" in words:
                    mail2.email()
            elif "खोलें" in words or "खोलो" in words or "खोलिए" in words or "चालू" in words:
                if "कैलकुलेटर" in words or "कैल्कुलेटर" in words or "कैल्क्यूलेटर" in words:
                    speak.tts('कैलकुलेटर खोल दिया गया है', lang)
                    os.system('calc.exe')
                elif "नोटपैड" in words:
                    speak.tts('नोटपैड खोल दिया गया है', lang)
                    os.system('notepad.exe')
                elif "पावर" in words or "PPT" in words:
                    if "पॉइंट" in words:
                        speak.tts('पावर पॉइंट खोल दिया गया है', lang)
                        filepath = "C:\Program Files (x86)\Microsoft Office\root\Office16"
                        os.system('start powerpnt.exe'.format(filepath))
                elif "वर्ड" in words:
                    speak.tts('वर्ड खोल दिया गया है', lang)
                    filepath = "C:\Program Files (x86)\Microsoft Office\root\Office16"
                    os.system('start winword.exe'.format(filepath))
                elif "PDF" in words:
                    speak.tts('PDF खोल दिया गया है', lang)
                    filepath = "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe"
                    os.system('start AcroRd32.exe'.format(filepath))
                elif "नोट" in words:
                    if "1" in words:
                        speak.tts('वन् नोट खोल दिया गया है', lang)
                        filepath = "C:\Program Files (x86)\Microsoft Office\root\Office16"
                        os.system('start onenote.exe'.format(filepath))
                elif "एक्सेल" in words or "XL" in words:
                    speak.tts('एक्सेल खोल दिया गया है', lang)
                    filepath = "C:\Program Files (x86)\Microsoft Office\root\Office16"
                    os.system('start excel.exe'.format(filepath))
            elif "लिरिक्स" in words:
                s = song.detail_input()
                print("\r\n")
                F = open(s[0] + "_" + s[1] + ".txt", 'r')
                ly = F.read()
                print(ly)
                F.close()
                os.remove(s[0] + "_" + s[1] + ".txt")
            else:
                try:
                    tx = translator.translate(text, dest='en')
                    app_id = "3WPY8L-LUUR9EVXXK"
                    client = wolframalpha.Client(app_id)
                    res = client.query(tx.text)
                    answer = next(res.results).text
                    ans = translator.translate(answer, dest='hi')
                    print(ans.text)
                except:
                    wikipedia.set_lang('hi')
                    print(wikipedia.summary(text, sentences=2))
def email():
    lang = 'en'
    server = smtplib.SMTP('smtp.gmail.com', 587)
    server.starttls()
    speak.tts('Enter recipient address', lang)
    r_add = input('Enter recipient address: ')
    server.login("*****@*****.**", "sirjibeproject")
    speak.tts('Say your message', lang)
    with sr.Microphone() as source:
        audio = r.listen(source)
    txt = r.recognize_google(audio)
    tx = translator.translate(txt)
    if tx.src == 'en':
        speak.tts('Your message was', lang)
        print(txt)
        server.sendmail("*****@*****.**", r_add, txt.encode())
        server.quit()
        speak.tts('Email has been sent', lang)
    else:
        lang = 'hi'
        speak.tts('आपका संदेश था', lang)
        txt = r.recognize_google(audio, language='hi')
        print(txt)
        server.sendmail("*****@*****.**", r_add, txt.encode())
        server.quit()
        speak.tts('ईमेल भेजा जा चुका है', lang)
コード例 #25
0
def discd():
    speak.tts('ok, discarding draft', 'en-us')
    add = driver.find_element_by_css_selector(".og")
    add.click()
    speak.tts('ok, discarded draft', 'en-us')
コード例 #26
0
def toad():
    win32api.SetCursorPos((900, 315))
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 200, 200, 0, 0)
    try:
        speak.tts('enter senders address', 'en-us')
        while True:
            r = sr.Recognizer()
            with sr.Microphone() as source:
                try:
                    speak.tts('listening', 'en-us')
                    speech = r.listen(source, timeout=2, phrase_time_limit=2)
                    text = r.recognize_google(
                        speech, key="AIzaSyBOti4mM-6x9WDnZIjIeyEU21OpBXqWBgw")

                    word = text.lower()
                    if word == 'done':
                        return
                    if word == 'back':
                        keyboard.press(Key.backspace)
                        keyboard.release(Key.backspace)
                        continue
                    if word in [
                            'at the rate gmail dot com',
                            'at the rate gmail dot kom', '@gmail.com',
                            'at the rate gmail.com'
                    ]:
                        word = '@gmail.com'
                    if word == 'space':
                        keyboard.press(Key.space)
                        keyboard.release(Key.space)
                        continue
                    if word == 'enter':
                        keyboard.press(Key.enter)
                        keyboard.release(Key.enter)
                        continue
                    if word == 'down':
                        keyboard.press(Key.down)
                        keyboard.release(Key.down)
                        continue
                    if word == 'aap':
                        keyboard.press(Key.up)
                        keyboard.release(Key.up)
                        continue
                    add = driver.find_element_by_class_name("vO")
                    add.send_keys(word)
                    speak.tts(word + ', ok', 'en-us')
                except Exception as e:
                    pass
    except Exception as e:
        add = driver.find_element_by_class_name("vO")
        driver.execute_script("return arguments[0].click();", add)
        speak.tts('enter senders address', 'en-us')
        while True:
            r = sr.Recognizer()
            with sr.Microphone() as source:
                try:
                    speak.tts('listening', 'en-us')
                    speech = r.listen(source, timeout=2, phrase_time_limit=2)
                    text = r.recognize_google(
                        speech, key="AIzaSyBOti4mM-6x9WDnZIjIeyEU21OpBXqWBgw")

                    word = text.lower()
                    if word == 'done':
                        return
                    if word == 'back':
                        keyboard.press(Key.backspace)
                        keyboard.release(Key.backspace)
                        continue
                    if word in [
                            'at the rate gmail dot com',
                            'at the rate gmail dot kom', '@gmail.com',
                            'at the rate gmail.com'
                    ]:
                        word = '@gmail.com'
                    if word == 'space':
                        keyboard.press(Key.space)
                        keyboard.release(Key.space)
                        continue
                    if word == 'enter':
                        keyboard.press(Key.enter)
                        keyboard.release(Key.enter)
                        continue
                    if word == 'down':
                        keyboard.press(Key.down)
                        keyboard.release(Key.down)
                        continue
                    if word == 'aap':
                        keyboard.press(Key.up)
                        keyboard.release(Key.up)
                        continue
                    add = driver.find_element_by_class_name("vO")
                    add.send_keys(word)
                    speak.tts(word + ', ok', 'en-us')
                except Exception as e:
                    pass
コード例 #27
0
def open():
    speak.tts('ok', 'en-us')
    keyboard.press(Key.enter)
    keyboard.release(Key.enter)
    return
コード例 #28
0
def ib():
    #driver = webdriver.Firefox()
    speak.tts('ok,opening inbox', 'en')
    driver.get('https://mail.google.com/mail/#inbox/')
    speak.tts('inbox opend', 'en')
    return
コード例 #29
0
import speech_recognition as sr
import webbrowser as wb
import speak

chrome_path = 'C:/Program Files (x86)/Mozilla Firefox/firefox.exe %s'

r = sr.Recognizer()

with sr.Microphone() as source:
    print('Say Something!')
    audio = r.listen(source)
    print('Done!')

try:
    text = r.recognize_google(audio)
    print('Google thinks you said:\n' + text)
    text = 'hello'
    lang = 'en'
    speak.tts(text, lang)

except Exception as e:
    print(e)
コード例 #30
0
def sm():
    speak.tts('ok,opening inbox', 'en')
    driver.get('https://mail.google.com/mail/#sent/')
    speak.tts('inbox opend', 'en')
    return