示例#1
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 {} and {} degree celcius now in {}".format(
        weather_com_result['current_conditions']['text'].lower(),
        weather_com_result['current_conditions']['temperature'], city_name)

    voice_module.speak(weather_result)
示例#2
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:
        speak('No music files found.')
        print("No music files found: {}".format(e))
示例#3
0
def play_random(music_path):
    try:
        music_listing = mp3gen(music_path)
        music_playing = random.choice(music_listing)
        speak("Now playing {}".format(music_playing))
        music_player(music_playing)
    except IndexError as e:
        speak('No music files found')
        print("No music files found: {}".format(e))
示例#4
0
def note_something(speech_text):
    conn = sqlite3.connect('memory.db')
    message = clean_message(speech_text, 'note')

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

    speak('Your note has been saved.')
示例#5
0
def show_all_notes():
    conn = sqlite3.connect('memory.db')
    speak('Your notes are as follows:')

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

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

    conn.close()
def connect_to_proxy(proxy_username, proxy_password):
    speak("Connecting to proxy server.")
    browser = webdriver.Firefox()
    browser.get('http://www.yopmail.com/en/')

    id_number = browser.find_element_by_name('login')
    # password = browser.find_element_by_name('password')

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

    browser.find_element_by_class_name('sbut').click()
示例#7
0
    def conversations():
        if check_message(['who', 'are', 'you']):
            speech_answer = general_conversation.who_are_you()
        elif check_message(['how', 'i', 'look']) or check_message(
            ['how', 'am', 'i']):
            speech_answer = general_conversation.how_am_i()
        elif check_message(['tell', 'joke']):
            speech_answer = general_conversation.tell_joke()
        elif check_message(['who', 'am', 'i']):
            speech_answer = general_conversation.who_am_i(name)
        elif check_message(['where', 'born']):
            speech_answer = general_conversation.where_born()
        elif check_message(['how', 'are', 'you']):
            speech_answer = general_conversation.how_are_you()
        else:
            speech_answer = general_conversation.undefined()

        speak(speech_answer)
示例#8
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("'", "")
        speak(wiki_data)
    except wikipedia.WikipediaException as e:
        speak('There was an error, could you be more specific?')
        print("Can you please be more specific? You may choose something from the following.; {0}".format(e))
示例#9
0
def news_reader():
    print
    news_dictionary
    for key, value in news_dictionary.items():
        speak('Headline, ' + key)
        speak('News, ' + value)
示例#10
0
from grey_matter.voice_module import speak

render = web.template.render('templates/')
urls = (
    '/',
    'index',
)

profile = open('profile.yaml')
profile_data = yaml.safe_load(profile)
profile.close()

# Functioning Variables
name = profile_data['name']

speak('Welcome {}, systems are now ready to run. How can I help you?')


class index:
    def GET(self):
        return render.index()

    def POST(self):
        x = web.input(myfile={})
        filedir = os.getcwd() + '/uploads'  # directory to store file in
        if 'myfile' in x:  # check if file object is created
            filepath = x.myfile.filename.replace(
                '\\', '/')  # replaces windows slashes for linux
            filename = filepath.split(
                '/'
            )[-1]  # split commands and chose the las part (filename with extension)
示例#11
0
import sys
import unicodedata

import yaml

from brain import brain
from grey_matter.ears import listen
from grey_matter.voice_module import speak

profile = open('profile.yaml')
profile_data = yaml.safe_load(profile)
profile.close()

# Functioning Variables
name = profile_data['name']
speak('Welcome, {}, systems are ready'.format(name))


def strip_accents(s):
    return ''.join(c for c in unicodedata.normalize('NFD', s)
                   if unicodedata.category(c) != 'Mn')


def main():
    while True:
        speech_text = ''
        for arg in sys.argv:
            if arg == '-t':
                speech_text = raw_input("What can I help you with?\n")

        if speech_text is '':
示例#12
0
def go_to_sleep():
    speak('Goodbye! Have a great day!')
    quit()
示例#13
0
def what_is_time():
    speak("The time is " + datetime.strftime(datetime.now(), '%H:%M:%S'))
示例#14
0
def open_firefox():
    speak('Aye aye captain, opening Firefox')
    webdriver.Firefox()