def define_subject(speech_text):
    words_of_message = speech_text.split()
    words_of_message.remove('define')
    cleaned_message = ' '.join(words_of_message)

    try:
        wiki_data = wikipedia.summary(cleaned_message, sentences=5)

        regEx = re.compile(r'([^\(]*)\([^\)]*\) *(.*)')
        m = regEx.match(wiki_data)
        while m:
            wiki_data = m.group(1) + m.group(2)
            m = regEx.match(wiki_data)

        wiki_data = wiki_data.replace("'", "")
        wiki_data = wiki_data.encode('ascii', 'ignore')
        r_data = wiki_data.split('.')
        t_data = r_data[0] + r_data[1]
        print t_data
        tts(t_data)

    except wikipedia.exceptions.DisambiguationError as e:
        tts('Can you please be more specific? You may choose something from the following.'
            )
        print(
            "Can you please be more specific? You may choose something from the following.;{0}"
            .format(e))
def news_reader():
    for key, value in news_dictionary.items():
        tts('Headline ' + key)
        tts('News ' + value)


#news_reader()
def how_am_i():
    replies = [
        'You are a person with good heart', 'You are a cute guy, sir',
        'You are goddamn handsome!, I wish to take you home', 'You are sexy!',
        'My knees go weak when I see you'
    ]
    tts(random.choice(replies))
示例#4
0
    def get_weather(self):
        city, country, coordinates = self.city, self.country, self.coordinates

        lat = coordinates.split(",")[0]
        lon = coordinates.split(",")[1]

        API_key = self.API_KEY

        if self.day == 1:

            try:
                r = requests.get(
                    self.OWM_LAT_LONG_API_URL.format(lat, lon, API_key))
            except:
                r = requests.get(self.OWM_CITY_API_URL.format(city, API_key))

            weather = r.json()

            temp = weather['main']['temp']
            temp_max = weather['main']['temp_max']
            temp_min = weather['main']['temp_min']
            sunrise = weather['sys']['sunrise']
            sunset = weather['sys']['sunset']
            windspeed = weather['wind']['speed']
            humidity = weather['main']['humidity']

            if temp > self.t2:
                type_temp = "Sunny"
            elif temp < self.t1:
                type_temp = "Chilly"
            elif temp > self.t3:
                type_temp = "Burning"
            elif self.t1 <= temp <= self.t2:
                type_temp = "Pleasant"

            # Convert UTC to datetime
            sunrise = datetime.fromtimestamp(sunrise).strftime("%H:%M")
            sunset = datetime.fromtimestamp(sunset).strftime("%H:%M")

            message = "Today is a {} day with temperature of {} degree Celsius. The maximum and minimum \
                            temperatures forecasted for today are {} and {} degree Celsius respectively. \
                          The windspeed for today is {} meters per second with a humidity of {} percentage. \
                          The sunrise and sunset are forecasted at {} AM and {} PM respectively".format(
                type_temp, temp, temp_max, temp_min, windspeed, humidity,
                sunrise, sunset)
            tts(message)

        else:
            day_start = datetime.now().date() - timedelta(days=self.day)
            day_end = datetime.now().date()

            try:
                r = requests.get(
                    self.OWM_HISTORY_LAT_LONG_API_URL.format(
                        lat, lon, API_key, day_start, day_end))
            except:
                r = requests.get(
                    self.OWM_HISTORY_CITY_API_URL.format(
                        city, API_key, day_start, day_end))
        pass
def who_are_you():
    messages = [
        'I am Melissa, your lovely personal assistant.',
        'Melissa, didnt I tell you before?',
        'You ask that so many times! I am Melissa.'
    ]
    tts(random.choice(messages))
def who_are_you():
    messages = [
        "I am Melissa, your lovely personal assistant.",
        "Melissa, didnt I tell you before?",
        "You ask that so many times! I am Melissa.",
    ]
    tts(random.choice(messages))
示例#7
0
def weather(city_name, city_code):
    weather_com_result = pywapi.get_weather_from_weather_com(city_code)
    weather_result = "Weather.com says: It is " + weather_com_result[
        'current_conditions']['text'].lower(
        ) + " and " + weather_com_result['current_conditions'][
            'temperature'] + "degree celcius now in " + city_name
    tts(weather_result)
示例#8
0
def tell_joke():
    jokes = [
        'What happens to a frogs car when it breaks down? It gets toad away',
        'Why was six scared of seven? Because seven ate nine.',
        'No, I always forget the pounch line.'
    ]
    tts(random.choice(jokes))
示例#9
0
def my_tweets():
    # This needs formatting, not currently fit to be run.
    tts('Loading your tweets, ' + name)
    auth = OAuthHandler(consumer_key, consumer_secret)
    auth.set_access_token(access_token, access_token_secret)
    api = tweepy.API(auth)
    timeline = api.user_timeline(count=10, include_rts=True)
示例#10
0
def vlounge_block():
	tts("directions for v lounge")
	link = "eog -f vlounge.png"
	os.system(link)
	

#xdotool getactivewindow windowkill
示例#11
0
def my_tweets():
    # This needs formatting, not currently fit to be run.
    tts('Loading your tweets, ' + name)
    auth = OAuthHandler(consumer_key, consumer_secret)
    auth.set_access_token(access_token, access_token_secret)
    api = tweepy.API(auth)
    timeline = api.user_timeline(count=10, include_rts=True)
def who_are_you():
    messages = [
        'I am your Personal Assistant.',
        'Your Personal Assistant, didnt I told you before?',
        'You ask that so many times! I am your Personal Assistant. '
    ]
    tts(random.choice(messages))
def who_are_you(profile_data):
    va_name = profile_data['va_name']
    messages = [
        'I am ' + va_name + ', your lovely personal assistant.',
        va_name + ', didnt I tell you before?',
        'You ask that so many times! I am ' + va_name
    ]
    tts(random.choice(messages))
def tell_joke():
    jokes = [
        'What happens to a frogs car when it breaks down? It gets toad away.',
        'Why was six scared of seven? Because seven ate nine.',
        'What is the difference between snowmen and snowwomen? Snowballs.',
        'No, I always forget the punch line.'
    ]
    tts(random.choice(jokes))
示例#15
0
def weather(city_name, city_zip):
    weather_com_result = pywapi.get_weather_from_weather_com(city_zip,
                                                             units="imperial")
    weather_result = "Weather.com says: It is " \
                     + weather_com_result['current_conditions']['text'].lower() \
                     + " and " + weather_com_result['current_conditions']['temperature']  \
                     + " degree farenheit now in " + city_name
    tts(weather_result)
def tell_joke():
    jokes = [
        "What happens to a frogs car when it breaks down? It gets toad away.",
        "Why was six scared of seven? Because seven ate nine.",
        "What is the difference between snowmen and snowwomen? Snowballs.",
        "No, I always forget the punch line.",
    ]
    tts(random.choice(jokes))
def how_am_i():
    replies = [
        "You are goddamn handsome!",
        "My knees go weak when I see you.",
        "You are sexy!",
        "You look like the kindest person that I have met.",
    ]
    tts(random.choice(replies))
def how_am_i():
    messages = ["You are very handsome!",
                "You look very good and smart",
                "My kneews go weak when I see you.",
                "Damn, I cant believe you are real, for you are that sexy!"]

    tts(random.choice(messages))

    pass
def play_random(music_path):
    try:
        music_listing = mp3gen(music_path)
        music_playing = random.choice(music_listing)
        tts("Now playing: " + music_playing)
        music_player(music_playing)
    except IndexError as e:
        tts('No music files found.')
        print("No music files found: {0}".format(e))
示例#20
0
def weather(city_name, city_code):
    api_address = 'http://api.openweathermap.org/data/2.5/weather?appid=60c9bd7f6a8da0632bd76ac138660b01&q='
    url = api_address + city_name
    json_data = requests.get(url).json()
    discript = json_data['weather'][0]['description']
    temp = json_data['main']['temp']
    message = "It is " + str(discript) + " and " + str(
        int(temp - 273)) + " degree celcius in Dehradun"
    tts(message)
示例#21
0
def play_random(music_path):
    try:
        music_listing = mp3gen(music_path)
        music_playing = random.choice(music_listing)
        tts("Now playing: " + music_playing)
        music_player(music_playing)
    except IndexError as e:
        tts('No music files found.')
        print("No music files found: {0}".format(e))
def tell_joke():
    jokes = [
        'What do you get when you cross-breed a shark and a cow? I have no idea but I wouldn’t try milking it.',
        'How can you tell you have a really bad case of acne? It’s when the blind try to read your face.',
        'What happens to a frogs car when it breaks down? It gets toad away.',
        'Why was six scared of seven? Because seven ate nine.',
        'No, I always forget the punch line.'
    ]
    tts(random.choice(jokes))
示例#23
0
def play_shuffle(music_path):
    try:
        music_listing = mp3gen(music_path)
        random.shuffle(music_listing)
        for i in range(0, len(music_listing)):
            music_player(music_listing[i])
    except IndexError as e:
        tts('No music files found')
        print("No music files found:{0}".format(e))
示例#24
0
def play_shuffle(music_path):
    try:
        music_listing = mp3gen(music_path)
        random.shuffle(music_listing)
        for i in range(0, len(music_listing)):
            music_player(music_listing[i])
    except IndexError as e:
        tts('No music files found.')
        print("No music files found: {0}".format(e))
示例#25
0
def show_all_notes():
    conn = sqlite3.connect('memory.db')
    tts('Your notes are as follows:')

    cursor = conn.execute("SELECT notes FROM notes")

    for row in cursor:
        tts(row[0])

    conn.close()
示例#26
0
def show_all_notes():
    conn = sqlite3.connect('memory.db')
    tts('Your notes are as follows:')

    cursor = conn.execute("SELECT notes FROM notes")

    for row in cursor:
        tts(row[0])

    conn.close()
def who_are_you():

    messages = ["Hi! I'm Scarlett, your own personal assistant! I'm self learning, and you to-do task list will keep on increasing!",
                "Scarlett! Didn't I tell you before?",
                "Scarlett! Didn't I tell you before? You are very forgetting!",
                "You ask that so many times! I'm Scarlett!"]

    tts(random.choice(messages))

    pass
def post_tweet(speech_text, consumer_key, consumer_secret, access_token,
               access_token_secret):
    words_of_message = speech_text.split()
    words_of_message.remove('tweet')
    cleaned_message = ' '.join(words_of_message).capitalize()
    auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
    auth.set_access_token(access_token, access_token_secret)
    api = tweepy.API(auth)
    api.update_status(status=cleaned_message)
    tts('Your tweet has been posted')
示例#29
0
def note_something(speech_text):
    conn = sqlite3.connect('memory.db')
    words_of_message = speech_text.split()
    words_of_message.remove('note')
    cleaned_message = ' '.join(words_of_message)

    conn.execute("INSERT INTO notes (notes, notes_date) VALUES (?, ?)", (cleaned_message, datetime.strftime(datetime.now(), '%d-%m-%Y')))
    conn.commit()
    conn.close()

    tts('Your note has been saved.')
示例#30
0
def show_all_uploads():
    conn = sqlite3.connect('memory.db')

    cursor = conn.execute("SELECT * FROM image_uploads")

    for row in cursor:
        print(row[0] + ': (' + row[1] + ') on ' + row[2])

    tts('Requested data has been printed on your terminal')

    conn.close()
def play_random(music_path):
    try:
        music_listing = mp3gen(music_path)
        music_playing = random.choice(music_listing)
        title = music_playing.replace(music_path + '/', '')
        title = title.replace('.mp3', '')
        tts("Now playing: " + title)
        music_player(music_playing)
    except IndexError as e:
        tts('No music files found.')
        print("No music files found: {0}".format(e))
示例#32
0
def youtube_open(speech_text):
	words_of_message = speech_text.split()
	words_of_message.remove('youtube')
	cleaned_message = ' '.join(words_of_message)
	tts('Opening youtube')
	browser = webdriver.Firefox()
	#browser.maximize_window()
	browser.get('https://www.youtube.com')
	search = browser.find_element_by_name('search_query')
	search.send_keys(cleaned_message)
	search.send_keys(Keys.RETURN)
示例#33
0
def connect_to_proxy(proxy_username, proxy_password):
    tts("Connecting to proxy server.")
    browser = webdriver.Firefox()
    browser.get('http://10.1.1.9:8090/httpclient.html')

    id_number = browser.find_element_by_name('username')
    password = browser.find_element_by_name('password')

    id_number.send_keys(proxy_username)
    password.send_keys(proxy_password)

    browser.find_element_by_name('btnSubmit').click()
示例#34
0
def note_something(speech_text):
    conn = sqlite3.connect('memory.db')
    words_of_message = speech_text.split()
    words_of_message.remove('note')
    cleaned_message = ' '.join(words_of_message)

    conn.execute(
        "INSERT INTO notes (notes, notes_date) VALUES (?, ?)",
        (cleaned_message, datetime.strftime(datetime.now(), '%d-%m-%Y')))
    conn.commit()
    conn.close()

    tts('Your note has been saved.')
def post_tweet(speech_text, consumer_key, consumer_secret, access_token, access_token_secret):

    words_of_message = speech_text.split()
    words_of_message.remove('tweet')
    cleaned_message = ' '.join(words_of_message).capitalize()

    auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
    auth.set_access_token(access_token, access_token_secret)

    api = tweepy.API(auth)
    api.update_status(status=cleaned_message)

    tts('Your tweet has been posted')
def faculty_search(speech_text):
	words_of_message = speech_text.split()
	words_of_message.remove('faculty')
	cleaned_message = ' '.join(words_of_message)
	name = cleaned_message.split()
	f_name = name[0]
	lname = name[1]
	tts('Searching for Faculty')
	browser = webdriver.Firefox()
	link = 'http://vit.edu.in/faculty/' + f_name + '-' + lname
	browser.get(link)
	search = browser.find_element_by_name('q')
	search.send_keys(cleaned_message)
	search.send_keys(Keys.RETURN)
示例#37
0
def define_subject(speech_text):
    words_of_message = speech_text.split()
    # change all words to lower text for case insensitive matching
    words_of_message[:] = [word.lower() for word in words_of_message]
    words_of_message.remove('define')
    cleaned_message = ' '.join(words_of_message)
    try:
        wiki_data = wikipedia.summary(cleaned_message, sentences=5)
        wiki_data = clean_msg(wiki_data)
        # Encode the text from wikipedia in utf8 so it is parsable by tts engine
        # see http://stackoverflow.com/a/5387966/2133539
        tts(wiki_data.encode('utf8'))
    except wikipedia.exceptions.DisambiguationError as e:
        tts('Can you please be more specific?')
        print(
            "Can you please be more specific? You may choose something from the following.; {0}"
            .format(e))
示例#38
0
def define_subject(speech_text):
    words_of_message = speech_text.split()
    words_of_message.remove('define')
    cleaned_message = ' '.join(words_of_message)

    try:
        wiki_data = wikipedia.summary(cleaned_message, sentences=5)

        regEx = re.compile(r'([^\(]*)\([^\)]*\) *(.*)')
        m = regEx.match(wiki_data)
        while m:
            wiki_data = m.group(1) + m.group(2)
            m = regEx.match(wiki_data)

        wiki_data = wiki_data.replace("'", "")
        tts(wiki_data)
    except wikipedia.exceptions.DisambiguationError as e:
        tts('Can you please be more specific? You may choose something from the following.')
        print("Can you please be more specific? You may choose something from the following; {0}".format(e))
def tell_joke():
    messages = ["What happends to a frogs car when it breaks down? It gets toad away!",
                "No, I always forget the punch line!",
                "What do I look to you? A Joker! I'm no joker! F**k off and don't ask for a joke! Haha just kidding, shoot right away another one!"]

    url = "http://api.icndb.com/jokes/random"

    resp = requests.get(url)
    # print(resp.content.decode())
    try:
        data = resp.json()
    except ValueError:
        data = random.choice(messages)
    # data = json.loads(resp.text)
    #
    # print(data)

    tts(data)

    pass
示例#40
0
def image_uploader(speech_text, client_id, client_secret, images_path):

    words_of_message = speech_text.split()
    words_of_message.remove('upload')
    cleaned_message = ' '.join(words_of_message)

    image_listing = img_list_gen(images_path)

    client = ImgurClient(client_id, client_secret)

    for i in range(0, len(image_listing)):
        if cleaned_message in image_listing[i]:
            result = client.upload_from_path(image_listing[i], config=None, anon=True)

            conn = sqlite3.connect('memory.db')
            conn.execute("INSERT INTO image_uploads (filename, url, upload_date) VALUES (?, ?, ?)", (image_listing[i], result['link'], datetime.strftime(datetime.now(), '%d-%m-%Y')))
            conn.commit()
            conn.close()

            print result['link']
            tts('Your image has been uploaded')
示例#41
0
def open_firefox():
    tts('Aye aye captain, opening Firefox')
    webdriver.Firefox()
示例#42
0
def feeling_angry():
    os.system('blink1-tool --cyan')
    tts('Calm down dear!')
示例#43
0
def very_dark():
    os.system('blink1-tool --white')
    tts('Better now?')
示例#44
0
def feeling_lazy():
    os.system('blink1-tool --yellow')
    tts('Rise and shine dear!')
示例#45
0
def feeling_creative():
    os.system('blink1-tool --magenta')
    tts('So good to hear that!')
def who_am_i(name):
    tts("You are " + name + ", a brilliant person. I love you!")
示例#47
0
def weather(city_name, city_code):
    weather_com_result = pywapi.get_weather_from_weather_com(city_code)
    weather_result = "Weather.com says: It is " + weather_com_result['current_conditions']['text'].lower() + " and " + weather_com_result['current_conditions']['temperature'] + "degree celcius now in " + city_name
    tts(weather_result)
示例#48
0
def what_is_time():
    tts("The time is " + datetime.strftime(datetime.now(), '%H:%M:%S'))
def undefined():
    tts("I dont know what that means!")
def news_reader():
    for key, value in news_dictionary.items():
        tts('Headline, ' + key)
        tts('News, ' + value)
def undefined():
    tts('I dont know what that means!')
def where_born():
    tts('I was created by a magician named Tanay, in India, the magical land of himalayas.')
示例#53
0
def very_dark():
    subprocess.call(['blink1-tool', '--white'])
    tts('Better now?')
def how_are_you():
    tts("I am fine, thank you.")
示例#55
0
def feeling_angry():
    subprocess.call(['blink1-tool', '--cyan'])
    tts('Calm down dear!')
def who_am_i(profile_data):
    name = profile_data['name']
    tts('You are ' + name + ', a brilliant person. I love you!')
def who_are_you(profile_data):
    va_name = profile_data['va_name']
    messages = ['I am ' + va_name + ', your lovely personal assistant.',
    va_name + ', didnt I tell you before?',
    'You ask that so many times! I am ' + va_name]
    tts(random.choice(messages))
def how_are_you():
    tts('I am fine, thank you.')