Esempio n. 1
0
def talk():
    #Checks to See If There Is Internet
    l = internetOn()

    if l == True:
        speechGoogle()  #More Accurate and Faster
    if l == False:
        say("There is no Internet connection")  #Offline
Esempio n. 2
0
def listen():
    while True:
        with sr.Microphone() as source:
            r.adjust_for_ambient_noise(source)
            print("Speak:")
            audio = r.listen(source)
        try:
            print("You said " + r.recognize_google(audio).upper())
            return r.recognize_google(audio).upper()
        except sr.UnknownValueError:
            print("Could not understand audio")
            say("NOTHING")
        except sr.RequestError as e:
            say("NOTHING")
            print("Could not request results; {0}".format(e))
Esempio n. 3
0
def temp():  #Tells The Temperature Using PiHat: Calibrate
    humidity = sense.get_humidity()
    sense.show_message("Humidity: " + str(humidity))

    temperature = int(sense.get_temperature())
    Celcius = str(temperature) + "C"
    temperature = int(temperature * 1.8 + 32)
    Fahren = str(temperature) + " Degrees Fahrenheit"

    say("The temperature is " + Fahren)

    Fahren1 = Fahren.replace("Degrees", "")
    sense.show_message(Fahren1)

    say("DONE")
Esempio n. 4
0
def quote():  #Get Quotes : Add option to get another
    while True:
        try:
            url = "http://api.forismatic.com/api/1.0/?method=getQuote&format=json&lang=en"
            req = requests.get(url)
            req = req.json()
            quote = req["quoteText"]
            print(quote)
            say(quote)
            say("DONE")
            break

        except Exception as e:
            say("ERROR")
            print(e)
Esempio n. 5
0
def ssh(available_SSH):  #Clean Up: Find Better Method
    availablePi = []

    say("Would you like me to tell you your SSH Options?")
    while True:
        try:
            recognized_Audio = "NO"
            if "YES" in recognized_Audio:
                for each in available_SSH.items():
                    say("For Pi {0}, the IP Address is {1}".format(
                        each[0], each[1][0]))
                    print(each[0], each[1])

                break
            if "NO" in recognized_Audio:
                say("Alright")
                break

        except Exception as e:
            print(e)
            say("NOTHING")
            continue

    say("Which Pi would you like to SSH in to?")
    while True:
        try:
            recognized_Audio = "1"
            if "ONE" in recognized_Audio:
                recognized_Audio = "1"

            if recognized_Audio in available_SSH:
                say("Going to Log in to Pi " + recognized_Audio)
                print(available_SSH[recognized_Audio])
                ADDRESS = available_SSH[recognized_Audio][0]
                USERNAME = available_SSH[recognized_Audio][1]
                PASSWORD = available_SSH[recognized_Audio][2]

                ssh = paramiko.SSHClient()
                ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
                ssh.connect(ADDRESS, username=USERNAME, password=PASSWORD)
                stdin, stdout, stderr = ssh.exec_command("ls")
                output = stdout.readlines()
                print(len(output))
                say("There are {0} entries in the Home Folder.".format(
                    len(output)))
                say("DONE")
                break

            elif recognized_Audio not in available_SSH:
                say("This is not a valid number.")
                print(recognized_Audio)
                print(available_SSH)
                continue

        except paramiko.ssh_exception.NoValidConnectionsError as e:
            say("Could not make the connection. SSH may not be enabled on the remote machine."
                )
            say("Would you like to try again?")
            recognized_Audio = listen()
            if "YES" in recognized_Audio:
                say("Retrying")
                continue
            if "NO" in recognized_Audio:
                say("Okay")
                break

        except paramiko.ssh_exception.AuthenticationException as e:
            say("There was an Authentication Error. You may want to go back to the CSV file and make the required changes."
                )
            break

        except Exception as e:
            print(e)
            say("NOTHING")
            continue
Esempio n. 6
0
def ipSend():  #Tells the IP Address of the Raspberry PI
    IPADDRESS = ni.ifaddresses("wlp3s0")[ni.AF_INET][0][
        'addr']  #Tells Current IP

    PUB_IP = requests.get("http://jsonip.com")
    PUB_IP = PUB_IP.json()["ip"]

    print(PUB_IP)
    say("The IP Address is {0}".format(IPADDRESS))

    say("And The Public IP Address is {0}".format(PUB_IP), slow=True)

    while True:
        say("EMAIL")
        try:
            recognized_Audio = listen()
            if "YES" in recognized_Audio:
                Combined_IP = [IPADDRESS, PUB_IP]
                sendMail(Combined_IP)
                print(Combined_IP)
                say("DONE")
                break
            if "NO" in recognized_Audio:
                say("DONE")
                break
        except Exception as e:
            say("NOTHING")
            continue
Esempio n. 7
0
def introduction():  #Just An Introduction
    say("Hello")
    say(""" My name is Tina.
    I was built in 2017 to be an artificial intelligence that's sole purpose
    is to make your life easier.""")
Esempio n. 8
0
def Google():  #Google Speech Recognizer for running commands
    now = datetime.datetime.now()
    nowTime = now.strftime("%I")
    nowTimeOfDay = now.strftime("%p")

    if nowTimeOfDay == "AM":
        print(MORNING)
        say("GOOD", TimeOfDay=MORNING)
    elif int(nowTime) <= 5 or int(nowTime) == 12 and nowTimeOfDay == "PM":
        print(DAY)
        say("GOOD", TimeOfDay=DAY)
    elif int(nowTime) >= 6 and nowTimeOfDay == "PM":
        print(EVENING)
        say("GOOD", TimeOfDay=EVENING)
    else:
        say("GOOD", "Day")

    while True:
        try:
            recognized_Audio = "INTRODUCE YOURSELF"  #listen()

            if "TEMPERATURE" in recognized_Audio:
                print(recognized_Audio)
                temp()
                break

            elif "ADDRESS" in recognized_Audio:
                print(recognized_Audio)
                ipSend()
                break

            elif "SSH" in recognized_Audio:
                print(recognized_Audio)
                ssh(available_SSH)
                break  #Make Dynamic

            elif "QUOTE" in recognized_Audio:
                print(recognized_Audio)
                quote()
                break

            elif "TEST" and "HAT" in recognized_Audio:
                print(recognized_Audio)
                hatTest()
                break

            elif ("MY NAME" in recognized_Audio) or ("INTRODUCE"
                                                     in recognized_Audio):
                print(recognized_Audio)
                introduction()
                break

            elif recognized_Audio == "GOOGLE":
                googleSearch()
                break

            else:
                say("NOTHING")

        except sr.UnknownValueError:
            say("NOTHING")
            continue

        except sr.RequestError as e:
            say("NOTHING")
            continue
    talk()