def play_video():
    bot.bot("What to play?")
    q = sr.Recognizer()
    t = 0
    with sr.Microphone() as source:
        print("Search for the term:")
        while t == 0:
            audio = q.listen(source, phrase_time_limit=5)
            try:
                query = q.recognize_google(audio)
                print('you said :{}'.format(query))
                t = 1
            except:
                print('Not understandable')
                print('Try again')
                t = 0

    query = "https://www.youtube.com/results?search_query=" + query.replace(
        ' ', '+')
    html = urllib.request.urlopen(query)
    url = re.findall(r"watch\?v=(\S{11})", html.read().decode())
    # print(html)
    # print(url)
    # print("http://www.youtube.com/watch?v=" + url[0])
    webbrowser.open("http://www.youtube.com/watch?v={}".format(url[0]))
Пример #2
0
def news():
    try:
        news_url = "https://news.google.com/news/rss"
        Client = urlopen(news_url)
        xml_page = Client.read()
        Client.close()
        soup_page = soup(xml_page, "xml")
        news_list = soup_page.findAll("item")
        for news in news_list[:15]:
            bot.bot(news.title.text.encode('utf-8'))
    except Exception as e:
        print(e)
def amazon_prime():
    bot.bot("Sure, opening amazon prime video")
    q = sr.Recognizer()
    t = 0
    with sr.Microphone() as source:
        bot.bot("what movie or web-series you want to watch?")
        while t == 0:
            audio = q.listen(source, phrase_time_limit=5)
            try:
                query = q.recognize_google(audio)
                print('you said :{}'.format(query))
                t = 1
            except:
                print('Not understandable')
                print('Try again')
                t = 0
    url_ott = "https://www.primevideo.com/search/?phrase=" + query.replace(
        " ", "%20") + "&ie=UTF8"
    webbrowser.open(url_ott)
Пример #4
0
def map():
    bot.bot("opening maps!")
    q = sr.Recognizer()
    t = 0
    with sr.Microphone() as source:
        bot.bot("what place you want to search for ?")
        print("search for the place:")
        while t == 0:
            audio = q.listen(source, phrase_time_limit=5)
            try:
                query = q.recognize_google(audio)
                print('you said :{}'.format(query))
                t = 1
            except:
                print('Not understandable')
                print('Try again')
                t = 0
    maps_url = "https://www.google.com/maps?q=" + query
    webbrowser.open(maps_url)
Пример #5
0
def search():
    bot.bot('What to search?')
    # listen()
    w = sr.Recognizer()
    t = 0
    with sr.Microphone() as source:
        print('Search for the term:')
        # print(t)

        while t == 0:
            audio = w.listen(source, phrase_time_limit=5)
            try:
                # print('in try block')
                query = w.recognize_google(audio).lower()
                print('you said :{}'.format(query))
                t = 1

            except:
                print('Not understandable')
                print('Try again')
                t = 0

    webbrowser.open("https://google.com/search?q=%s" % query)
Пример #6
0
def shop():
    bot.bot("what you want to shop?")
    q = sr.Recognizer()
    t = 0
    with sr.Microphone() as source:
        print("search for the term:")
        while t == 0:
            audio = q.listen(source, phrase_time_limit=5)
            try:
                query = q.recognize_google(audio)
                print('you said :{}'.format(query))
                bot.bot('Here you go')
                bot.bot('Happy shopping!')
                t = 1
            except:
                print('Not understandable')
                print('Try again')
                t = 0
    url = "https://www.amazon.in/s?k=" + query
    webbrowser.open(url)
def calendar():
    bot.bot("Opening Calendar")
    url = "https://calendar.google.com/calendar/"
    # webbrowser.open(url)
    return ()
Пример #8
0
def main():
    bot.bot("Searching for Notes")
    try:
        if user.user == 0:
            file = open("general.txt", "r")
            bot.bot(file.read())
        elif user.user == 1:
            file = open("user_1.txt", "r")
        elif user.user == 2:
            file = open("user_2.txt", "r")
        elif user.user == 3:
            file = open("user_3.txt", "r")

    except FileNotFoundError:
        bot.bot("No notes are available.")
        bot.bot("Want to created one now?")
        q = sr.Recognizer()
        t = 0
        with sr.Microphone() as source:
            while t == 0:
                audio = q.listen(source, phrase_time_limit=5)
                try:
                    res = q.recognize_google(audio)
                    t = 1
                    if "yes" in res:
                        bot.bot("What should I write?")
                    elif user.user == 0:
                        cli.utils.notes.write("0")
                    elif user.user == 1:
                        cli.utils.notes.write("1")
                    elif user.user == 2:
                        cli.utils.notes.write("2")
                    elif user.user == 3:
                        cli.utils.notes.write("3")
                    else:
                        bot.bot("Okay, exiting the note section")
                except:
                    print('Not understandable')
                    print('Try again')
                    t = 0
        bot.bot("A new note is created!")