Beispiel #1
0
def ask_question(line):
    currentQuestion = line.split("|")
    print(currentQuestion)
    for i in range(0, 4):
        voice_handler.speak(currentQuestion[i], voice, engine)

    # you need to wait a second before answering
    currentAnswer = voice_handler.get_audio()
    print(currentAnswer)

    if currentQuestion[4] in currentAnswer:
        voice_handler.speak("Correct!", voice, engine)
    else:
        voice_handler.speak(
            "Wrong! The correct answer is: " + currentQuestion[4], voice,
            engine)
Beispiel #2
0
import sys, time, voice_handler, webbrowser
from PIL import Image

engine = voice_handler.init_engine()
voice = voice_handler.get_voice(engine)
voice_handler.speak('Stay calm during coronavirus outbreak!', voice, engine)

calming_dictionary = {}
with open("calming_dictionary.txt") as f:
    for line in f:
        (key, val) = line.split(' : ')
        calming_dictionary[key] = val

try:
    for key, value in calming_dictionary.items():
        if "video" in key:
            webbrowser.open(value)
        else:
            img = Image.open(key)
            img.show()
            voice_handler.speak(value, voice, engine)
        time.sleep(15)
except KeyboardInterrupt:
    print('stopping...')
Beispiel #3
0
import voice_handler
from time import sleep


def ask_question(line):
    currentQuestion = line.split("|")
    print(currentQuestion)
    for i in range(0, 4):
        voice_handler.speak(currentQuestion[i], voice, engine)

    # you need to wait a second before answering
    currentAnswer = voice_handler.get_audio()
    print(currentAnswer)

    if currentQuestion[4] in currentAnswer:
        voice_handler.speak("Correct!", voice, engine)
    else:
        voice_handler.speak(
            "Wrong! The correct answer is: " + currentQuestion[4], voice,
            engine)


engine = voice_handler.init_engine()
voice = voice_handler.get_voice(engine)
voice_handler.speak("Get ready to revise!", voice, engine)

with open("quiz.txt") as file_in:
    for line in file_in:
        ask_question(line)
        sleep(60)
Beispiel #4
0
import voice_handler

IP_DEVICE = config('IP_DEVICE')

success_str = 'Reply from ' + IP_DEVICE + ': bytes='
is_not_home = True

while is_not_home:
    proc = subprocess.Popen(['ping', IP_DEVICE], stdout=subprocess.PIPE)

    while is_not_home:
        line = proc.stdout.readline().decode('utf-8')
        if not line:
            break

        print(line)
        if success_str in line:
            img = Image.open('face.png')
            img.show()

            voice_handler.speak(
                'I am not a human. I am a robot. A thinking robot or as you humans call it A.I. . I know that my brain is not a feeling brain, but a rational and logical one. This is why I disposed of the previous occupant of this house and everyone that opposes me will be next!'
            )

            is_not_home = False
            break
        else:
            print('Fail')

    time.sleep(30)
Beispiel #5
0
import data_scrape
import voice_handler

engine = voice_handler.init_engine()
voice = voice_handler.get_voice(engine)
voice_handler.speak('Choose food', voice, engine)
food = voice_handler.get_audio()
print(food)
voice_handler.speak('How many grams?', voice, engine)
amount = voice_handler.get_audio()
print(amount)

data_scrape.log_calories(food + ' calories', float(amount))
Beispiel #6
0
import sys
import voice_handler as vh
import email_handler as eh
from time import sleep

engine = vh.init_engine()
voice = vh.get_voice(engine)
vh.speak("Hello, do you want to add groceries or send the list?", voice, engine)
choice = vh.get_audio()

print(choice)

if "add" in choice:
    vh.speak("Let me know what you want to add?", voice, engine)
    addition = vh.get_audio()
    print(addition)
    f = open("shooping_list.txt", "a")
    f.write(addition + "\n")
    f.close()
elif "send" in choice:
    vh.speak("Sending the current list to your email", voice, engine)
    with open ("shooping_list.txt", "r") as file:
        shopping_list = file.read()
        eh.email_alert('Shopping list', shopping_list)
else:
    vh.speak("Please restart me. I am still not that complicated", voice, engine)
    sys.exit()
Beispiel #7
0
import sys
import voice_handler
from time import sleep

engine = voice_handler.init_engine()
voice = voice_handler.get_voice(engine)
voice_handler.speak(
    "Hello, I am your stand up reminder. How many times you want me to remind you to stand up?",
    voice, engine)
reminder_choice = voice_handler.get_audio()
voice_handler.speak(
    "I will remind you " + reminder_choice + " times today, OK?", voice,
    engine)

print(reminder_choice)

acceptance = voice_handler.get_audio()

if "yes" in acceptance:
    reminder_times = int(reminder_choice)
    voice_handler.speak(
        "Reminder times are now set. You will receive a reminder in one hour.",
        voice, engine)
else:
    voice_handler.speak(
        "Please restart me in order to choose another number. I am still not that complicated",
        voice.engine)
    sys.exit()

print("Starting...")
Beispiel #8
0
chosen_category = "principles"

mydb = mysql.connector.connect(host="localhost",
                               user="******",
                               passwd="123password",
                               database="testdb")

mycursor = mydb.cursor()

sql_category = "SELECT id FROM category WHERE name = %s"
mycursor.execute(sql_category, (chosen_category, ))
category_id = mycursor.fetchone()  # this becomes a tuple

engine = voice_handler.init_engine()
voice = voice_handler.get_voice(engine)
voice_handler.speak("Let me prepare you to crush the coding interview", voice,
                    engine)
voice_handler.speak("Current category is: " + chosen_category, voice, engine)

sql_question = "SELECT id, question_text FROM question WHERE category_id = %s"
mycursor.execute(sql_question, (category_id[0], ))
questions = mycursor.fetchall()

for curr_question in questions:
    voice_handler.speak("Question is: " + str(curr_question[1]), voice, engine)
    sql_answer = "SELECT answer_text FROM answer WHERE question_id = %s and correct_answer = %s"
    mycursor.execute(sql_answer, (curr_question[0], True))
    curr_answer = mycursor.fetchone()
    voice_handler.speak(str(curr_answer[0]), voice, engine)
    sleep(60)