Esempio n. 1
0
def handleInput():
    while True:

        text = input("Question:\n")
        ohbot.say(text)
        ohbot.eyeColour(10, 5, 0, True)
        randIndex = randrange(0, len(connectingPhrases))

        choice = connectingPhrases[randIndex]
        ohbot.move(ohbot.HEADTURN, 5)
        ohbot.move(ohbot.EYETILT, 7)
        ohbot.move(ohbot.HEADNOD, 9)
        ohbot.say(choice)

        try:
            res = wolfclient.query(text)
            ans = next(res.results).text
            ans = ans.replace("|", ".")
            ohbot.say(ans)
            ohbot.eyeColour(0, 10, 0, True)

        except:

            print('Answer not available')
            ohbot.say("Answer not available")
            ohbot.eyeColour(10, 0, 0, True)

        ohbot.move(ohbot.HEADTURN, 5)
Esempio n. 2
0
def handleInputWiki():
    while True:

        text = input("Define:\n")
        ohbot.say(text)
        ohbot.eyeColour(10, 5, 0, True)
        randIndex = randrange(0, len(connectingPhrases))

        choice = connectingPhrases[randIndex]
        ohbot.move(ohbot.HEADTURN, 5)
        ohbot.move(ohbot.EYETILT, 7)
        ohbot.move(ohbot.HEADNOD, 9)
        ohbot.say(choice)

        try:
            res = wikipedia.summary(text)
            ohbot.say(res)
            ohbot.eyeColour(0, 10, 0, True)

        except:

            print('Answer not available')
            ohbot.say("Answer not available")
            ohbot.eyeColour(10, 0, 0, True)
            ohbot.move(ohbot.HEADTURN, 5)
Esempio n. 3
0
def withMe():
    hour = int(datetime.datetime.now().hour)
    if hour >= 0 and hour < 12:
        ohbot.say("Good morning!")
    elif hour >= 12 and hour < 18:
        ohbot.say("Good Afternoon")
    else:
        ohbot.say('Good Evening')
    ohbot.say("I am ohbot. How may I help you?")
Esempio n. 4
0
def handleInputWiki(text):
    if not text == None:
        ohbot.say("You ask this question to me " + text)
        ohbot.setEyeColour(10, 5, 0, True)
        randIndex = randrange(0, len(connectingPhrases))

        choice = connectingPhrases[randIndex]
        ohbot.move(ohbot.HEADTURN, 5)
        ohbot.move(ohbot.EYETILT, 7)
        ohbot.move(ohbot.HEADNOD, 9)
        ohbot.say(choice)

        try:
            res = wikipedia.summary(text)
            ohbot.say(res)
            ohbot.setEyeColour(0, 10, 0, True)

        except:

            print('Answer not available')
            ohbot.say("Answer not available")
            ohbot.setEyeColour(10, 0, 0, True)
            ohbot.move(ohbot.HEADTURN, 5)
Esempio n. 5
0
            # 	return(row[1])

            if counter == number - 1:
                return (row[1])
            counter = counter + 1


# sentence = get_csv_text(0)

# sys.argv[1] means any number passed here as a string
sentence = get_csv_text(int(sys.argv[1]))
print("what is sys.argv? " + str(sys.argv[1]) + " " + str(type(sys.argv[1])))
print(sentence)
# print("saying:", sys.argv[1])

# sys.argv[1] is the number of the sentence to say
# grab the sentence from csv file here:

# ohbot.setVoice("-ven+croak")

# ohbot.setVoice("-vfr+f1 -p99 -s180")
# https://github.com/ohbot/ohbot-python
# ohbot.setVoice("-ven-us -a200 ")
# ohbot.say(sentence)

ohbot.setVoice("-ven-us+f2")
# ohbot.say(sentence)

# # say the sentence
ohbot.say(sentence)
Esempio n. 6
0
'''
The ohbot.move() function needs at least 2 arguments: movement name and desired position.

ohbot.HEADTURN
ohbot.HEADNOD
ohbot.EYETURN
ohbot.EYETILT
ohbot.BOTTOMLIP
ohbot.LIDBLINK

position can be any number 0-10.

'''
# Move the HEADTURN motor to 2.
ohbot.move(ohbot.HEADTURN, 2)
ohbot.say("head turn to 2")
# Move the HEADTURN motor to 5.
ohbot.move(ohbot.HEADTURN, 5)
ohbot.say("head turn to 5")

# Move the HEADNOD motor to 9.
ohbot.move(ohbot.HEADNOD, 9)
ohbot.say("head nod to 9")
# Move the HEADNOD motor to 5.
ohbot.move(ohbot.HEADNOD, 5)
ohbot.say("head nod to 5")
'''
The ohbot.move() function can also take an optional third arguement 'spd'
to change the speed of the movement. If unspecified speed defaults to 5. 
'''
Esempio n. 7
0
# +croak or +whisper
# -a for amplitude (0 to 200)
# -s for speed 80 to 500
# -p for pitech 0 to 99

# ESPEAK-NG
# supports some of the ESPEAK but some is missing

# import the ohbot module
from ohbot import ohbot

# Reset Ohbot
ohbot.reset()

# Default synthesizer SAPI.  Default Voice as set in Control Panel
ohbot.say("I.  I just took a ride")
# Quieter
ohbot.setVoice("-a82")
ohbot.say("In a silver machine.")
# Faster
ohbot.setVoice("-r4")
ohbot.say("And I'm still feeling mean.")
# Slower
ohbot.setVoice("-r-4")
ohbot.say("Do you wanna ride? See yourself going by.")
# American
ohbot.setVoice("-vzira")
ohbot.say("The other side of the sky.")
# Default voice
ohbot.setVoice("")
ohbot.say("I got a silver machine.")
Esempio n. 8
0
def emotion_reflect(label):
    global last_label
    try:
        if not label == last_label:
            if label == 'Angry':
                ohbot.say("angry")
            elif label == 'Happy':
                ohbot.say("happy")
            elif label == 'Neutral':
                ohbot.say("neutral")
            elif label == 'Sad':
                ohbot.say('sad')
            elif label == 'Surprise':
                ohbot.say("surprised")
            elif label == "No Face Found!":
                ohbot.say("look at me!")
            last_label = label
    except:
        print("label failed")
Esempio n. 9
0
ohbot.reset()
ohbot.wait(1)

# Set the moving and blinking global variables to True.
moving = True
blinking = True

# Create a thread for blinking.
t1 = threading.Thread(target=blinkLids, args=())

# Create a thread to make eyes look around randomly.
t2 = threading.Thread(target=randomLook, args=())

# Create a thread for random head nod positions.
t3 = threading.Thread(target=randomNod, args=())

# Create a thread for random head turn positions.
t4 = threading.Thread(target=randomTurn, args=())

# Create a thread for random base colour.
t5 = threading.Thread(target=eyeCol, args=())

# Start the threads.
t1.start()
t2.start()
t3.start()
t4.start()
t5.start()

ohbot.say("Hello my name is Ohbot")
Esempio n. 10
0
        ohbot.wait(randint(0, 3))


def blinking():

    while True:

        ohbot.move(ohbot.LIDBLINK, 0, 10)

        ohbot.wait(random() / 3)

        ohbot.move(ohbot.LIDBLINK, 10, 10)

        ohbot.wait(randint(0, 6))


t = threading.Thread(target=moveLoop, args=())

if wiki:
    t2 = threading.Thread(target=handleInputWiki, args=())
else:
    t2 = threading.Thread(target=handleInput, args=())

t3 = threading.Thread(target=blinking, args=())

t.start()
t2.start()
t3.start()

ohbot.say("Hello ohbot here, please type in a question")
Esempio n. 11
0
def get_steven_to_talk():
    """Run the Ohbot routine
    Returns:
        Boolean True or False depending on whether run successfully or not
    """

    try:
        # Reset Ohbot

        ohbot.reset()

        # Switch the speech synthesizer to epseak
        ohbot.setSynthesizer("espeak")

        # Set the voice to english West Midlands accent medium speed.

        ohbot.setVoice("-ven+f2 -s130")

        # Set eyes to red
        ohbot.eyeColour(10, 0, 0)

        ohbot.wait(0.5)

        # Say something
        ohbot.say("Good Evening", True, False, False, 0)
        ohbot.wait(0.5)
        #ohbot.say("Who have we got here",True, False, False,0)
        #ohbot.wait(0.5)
        ohbot.say("I'm the late great Mary Webb ", True, False, False, 0)
        ohbot.wait(0.5)
        ohbot.say("I love children ", True, False, False, 0)
        ohbot.wait(0.5)
        ohbot.say("For supper", True, False, False, 0)
        ohbot.wait(0.5)
        #ohbot.say("Woooahhhh woooahhha",True, False, False,0)
        #ohbot.wait(0.5)
        # Wait a few seconds for the motors to move

        ohbot.wait(2)

        # Move head left to right
        ohbot.move(ohbot.HEADTURN, 4, 1)
        ohbot.wait(0.5)
        ohbot.move(ohbot.HEADTURN, 6, 1)
        ohbot.wait(0.5)
        ohbot.move(ohbot.HEADTURN, 5, 1)
        ohbot.wait(0.5)
        ohbot.eyeColour(0, 10, 0)
        ohbot.wait(0.5)
        ohbot.move(ohbot.HEADNOD, 7, 1)
        ohbot.wait(0.5)
        ohbot.move(ohbot.HEADNOD, 1, 1)
        ohbot.wait(0.5)
        ohbot.move(ohbot.EYETURN, 9, 1)
        ohbot.wait(0.5)
        ohbot.move(ohbot.EYETURN, 1, 1)
        ohbot.wait(0.5)
        ohbot.move(ohbot.EYETURN, 5, 1)
        ohbot.wait(0.5)
        ohbot.say("Take one sweet.", True, False, False, 0)
        ohbot.wait(0.5)
        ohbot.say("At your own risk", True, False, False, 0)
        ohbot.wait(0.5)
        ohbot.say("Don't forget to brush your teeth", True, False, False, 0)
        ohbot.wait(0.5)
        ohbot.say("Happy Halloween", True, False, False, 0)
        ohbot.wait(0.5)
        ohbot.reset()
        # close ohbot at the end.
        ohbot.wait(0.5)
        ohbot.close()
        ohbot.wait(0.5)
        return True
    except:
        return False
Esempio n. 12
0
# Install pico2wave using sudo apt-get install libttspico-utils
# Ensure you are running the latest version of the library by running sudo pip3 install ohbot --upgrade

from ohbot import ohbot

ohbot.reset()

ohbot.setSynthesizer("pico2wave")

ohbot.say("now I can speak using pico2wave text to speech as well")

ohbot.wait(1)

ohbot.close()

Esempio n. 13
0
def cKey(event):
    ohbot.say("Hello humans", untilDone=False)
    ohbot.setEyeColour(3, 10, 3)
Esempio n. 14
0
def bKey(event):
    ohbot.playSound('spring', untilDone=True)
    ohbot.say("What is going on ?", untilDone=False)
    ohbot.setEyeColour(10, 3, 3)
Esempio n. 15
0
def aKey(event):
    ohbot.say("Hello I am Ohbot", untilDone=False)
    ohbot.setEyeColour(3, 3, 10)
Esempio n. 16
0
# Reset Ohbot

ohbot.reset()

# Move turn ohbot's head and eyes. 
ohbot.move(1,2)
ohbot.move(3,1)

# Wait a few seconds for the motors to move

ohbot.wait(2)

# Move head back to the centre and say "Hello World"
ohbot.move(1,5,1)
ohbot.say("Hello World")

# Slowly increase the brightness of the eyes.

for x in range(0,10):

    ohbot.eyeColour(x,x,x)
    ohbot.wait(0.1)

    ohbot.eyeColour(0,0,0)
    ohbot.wait(0.2)

    

ohbot.move(1,5,1)
ohbot.wait(1)
Esempio n. 17
0
from ohbot import ohbot

## Example program for using sensors with ohbot.
## Tilt sensor - a3
## Light sensor - a4

ohbot.reset()
while True:

    val1 = ohbot.readSensor(4)

    val2 = ohbot.readSensor(3)

    ohbot.setEyeColour(val2, 10 - val2, 0, True)
    ohbot.move(ohbot.HEADTURN, val2)
    print(val2)
    if val1 > 2:
        ohbot.say("put me down")

    if val2 < 2:
        ohbot.say("who turned out the lights")

    ohbot.wait(0.1)
Esempio n. 18
0
from ohbot import ohbot
import random

ohbot.reset()

ohbot.wait(0.2)

ohbot.say("Commencing hardware tests")

ohbot.say("Eyes to red")
ohbot.setEyeColour(10, 0, 0, True)

ohbot.say("Eyes to green")
ohbot.setEyeColour(0, 10, 0, True)

ohbot.say("Eyes to blue")
ohbot.setEyeColour(0, 0, 10, True)

ohbot.say("HeadTurn motor 0 to 10")

for x in range(0, 10):

    ohbot.move(ohbot.HEADTURN, x)
    ohbot.wait(0.2)

ohbot.move(ohbot.HEADTURN, 5)

ohbot.say("HeadNod motor 0 to 10")

for x in range(0, 10):
Esempio n. 19
0
from ohbot import ohbot

import random

# Run 'say -v?' in Terminal to list options for voices. speechSpeed is 90 +.

ohbot.reset()

ohbot.say("Hi it is great to be here, i am finally running on a mac, wow")

ohbot.wait(2)

ohbot.setVoice("Karen")

ohbot.setSpeechSpeed(150)

ohbot.move(ohbot.HEADTURN, random.randint(3, 6))

ohbot.say("hello i am Karen")

ohbot.setVoice("Alex")

ohbot.setSpeechSpeed(90)

ohbot.move(ohbot.HEADTURN, random.randint(2, 6))

ohbot.say("hello i am Alex slow")

ohbot.setVoice("Oliver")

ohbot.move(ohbot.HEADTURN, random.randint(1, 6))
Esempio n. 20
0
t3 = threading.Thread(target=randomNod, args=())

# 创建随机转头线程
t4 = threading.Thread(target=randomTurn, args=())

# 创建眼睛随机颜色线程
t5 = threading.Thread(target=eyeCol, args=())

# 启动所有线程
t1.start()
# t2.start()
# t3.start()
# t4.start()
# t5.start()

ohbot.say("hello")

while True:
    # 捕获视频
    ret, frame = cap.read()
    labels = []
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    faces = face_classifier.detectMultiScale(gray, 1.3, 5)

    for (x, y, w, h) in faces:
        cv2.rectangle(frame, (x, y), (x + w, y + h), (255, 0, 0), 2)
        roi_gray = gray[y:y + h, x:x + w]
        roi_gray = cv2.resize(roi_gray, (48, 48), interpolation=cv2.INTER_AREA)
        rect, face, image = face_detector(frame)
        if np.sum([roi_gray]) != 0:
            roi = roi_gray.astype('float') / 255.0
Esempio n. 21
0
        #now that eyes are open start blinking on a different thread
        blinking = True
        t = threading.Thread(target=blinkLids, args=())
        t.start()

        #turn the head to each side then back to centre
        sleep(0.5)
        ohbot.move(ohbot.HEADTURN, 10)
        sleep(0.5)
        ohbot.move(ohbot.HEADTURN, 0)
        sleep(0.5)
        ohbot.move(ohbot.HEADTURN, 5)

        #set hdmiAudio to True here if you are using hdmiAudio and speech is missing at beginning of each phrase
        ohbot.say(say, untilDone=False, lipSync=True, hdmiAudio=False)

        #swivel eyes side to side 5 times
        for i in range(0, 5):
            ohbot.move(ohbot.EYETURN, 10, 10)
            sleep(0.1)
            ohbot.move(ohbot.EYETURN, 0, 10)
            sleep(0.1)

        #eye swivel back to centre
        ohbot.move(ohbot.EYETURN, 5, 10)

        #go to sleep position and turn eyes off
        sleep(3)
        blinking = False
        #wait a second for the thread to stop
Esempio n. 22
0
#start up sequence resets to mid position, sets the eyes to blue then goes to sleep
ohbot.reset()
ohbot.eyeColour(0, 0, 10)
sleep(1.0)
ohbot.eyeColour(0, 0, 0)

# Start a thread for the blinking.
blinking = True
t = threading.Thread(target=blinkLids, args=())
t.start()

sleep(2.0)

ohbot.say(
    "The ohbot pi library now supports e speak meaning i can speak different languages and in different voices"
)

ohbot.move(ohbot.HEADTURN, 4)
ohbot.wait(0.2)
ohbot.move(ohbot.HEADTURN, 6)
ohbot.wait(0.2)

# Set the voice to English female medium speed.

ohbot.setVoice("-ven+f2 -s150")
ohbot.eyeColour(3, 10, 2)
ohbot.say("you can even change voice mid program")

# Set the voice to French female.