示例#1
0
def wish_morning():
    wm = [
        'Good thoughts precede great deeds. Great deeds precede success. Have a great day.',
        'This is not just another day, this is yet another chance to make your dreams come true. Good morning.'
    ]
    a = random.randint(0, 1)
    tts.voice(wm[a])
示例#2
0
def wish_night():
    wn = [
        'Do you think about me before you go to sleep? Good night.',
        'I just wanted to let you know I think of you. Good Night',
        'I am already missing you. Good night'
    ]
    b = random.randint(0, 2)
    tts.voice(wn[b])
示例#3
0
文件: weather.py 项目: yog-singh/Lucy
def temp():
    url = "http://api.openweathermap.org/data/2.5/weather?lat=22.57&lon=88.36&appid=ddc80cbc49644abd43d989deb781d0e3&mode=xml"
    response = urllib.urlopen(url)
    data = ET.parse(response)
    root = data.getroot()
    temp = root[1].attrib
    temp_val = float(temp['value']) - 273
    text = "The temperature is " + str(int(temp_val)) + " degree Celsius"
    tts.voice(text)
示例#4
0
def no_rep():
    nr = [
        'Let me be sure I understand which information you are looking for.',
        'Thats a timely question, because I am currently gathering information on that.',
        'This is scary for me to say, so I am hoping you can really hear me and try not to judge me or give me any advice.',
        ' I will totally take a look at that.'
    ]
    n = random.randint(0, 3)
    tts.voice(nr[n])
示例#5
0
def search(query):
    try:
        result = wikipedia.summary(query, sentences=1)
        tts.voice(result)
    except wikipedia.exceptions.DisambiguationError as de:
        error = de.options
        print(error[0])
    except wikipedia.exceptions.PageError as pe:
        error = pe.error
        tts.voice("Nothing found on Wikipedia.")
示例#6
0
文件: weather.py 项目: yog-singh/Lucy
def weather():
    url = "http://api.openweathermap.org/data/2.5/weather?lat=22.57&lon=88.36&appid=ddc80cbc49644abd43d989deb781d0e3&mode=xml"
    response = urllib.urlopen(url)
    data = ET.parse(response)
    root = data.getroot()
    temp = root[1].attrib
    humid = root[2].attrib
    cloud = root[5].attrib
    temp_val = float(temp['value']) - 273
    humid_val = int(humid['value'])
    cloud_type = cloud['name']
    text = "The temperature is " + str(
        int(temp_val)) + " degree Celsius " + str(
            humid_val) + 'percent humidity and' + cloud_type
    tts.voice(text)
示例#7
0
文件: bt.py 项目: yog-singh/Lucy
def unlock():
    results = search()
    if not results:
        tts.voice('No keys found')
    for addr in results:
        if (addr == phone):
            tts.voice("Door Unlocked.")
            motor.open()
            break
        else:
            tts.voice("Key not found.")
示例#8
0
def joke():
    response = urllib2.urlopen("http://tambal.azurewebsites.net/joke/random")
    data = json.load(response)
    tts.voice(data['joke'])
示例#9
0
    tts.voice(wm[a])


def edit():
    os.system('echo "NULL" > /var/www/html/test/val.txt')


while True:
    with open('/var/www/html/test/val.txt') as data_file:
        val = data_file.readline()
    val = val.upper()
    if 'LIGHTS' in val:
        if 'BEDROOM' in val:
            if 'ON' in val:
                GPIO.output(11, True)
                tts.voice("Bedroom Lights on.")
                edit()

            elif 'OFF' in val:
                GPIO.output(11, False)
                tts.voice("Bedroom Lights off.")
                edit()

        if ('LIVING' in val and 'ROOM' in val):
            if 'ON' in val:
                GPIO.output(12, True)
                tts.voice("Living room Lights on.")
                edit()

            elif 'OFF' in val:
                GPIO.output(12, False)