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)
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)
lastm = "" #this is called on a separate thread to blink the eyes while running def blinkLids(): while (blinking): ohbot.move(ohbot.LIDBLINK, 0) sleep(0.2) ohbot.move(ohbot.LIDBLINK, 10) #wait for a random amount of time for realistic blinking sleep(randint(0, 4)) #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) ohbot.move(ohbot.HEADNOD, 0) ohbot.move(ohbot.LIDBLINK, 0) sleep(2.0) #close to turn the motors off ohbot.close() while (True): #get seconds and minutes into strings s = strftime("%S", localtime()) m = strftime("%M", localtime()) #set this to False for testing to make Ohbot speak continuously everyQuarterHour = True if ((everyQuarterHour == False) or
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) ohbot.say("Now I am running in python you know",False) for x in range (0,10): ohbot.move(3,x) ohbot.eyeColour(x,10-x,x)
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.eyeColour(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)
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
blinking = False #this is called on a separate thread to blink the eyes while running def blinkLids(): while (blinking): ohbot.move(ohbot.LIDBLINK, 0) sleep(0.2) ohbot.move(ohbot.LIDBLINK, 10) #wait for a random amount of time for realistic blinking sleep(randint(0, 4)) #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)