robot.changeImage("Content.jpg") def knownPerson(robot): ''' We'll call this function when we encounter an uknown person NOTE: The assets on your robot will probably be different. Be sure to check what assets are on your robot with /api/images GET call (Populate Image list on API Explorer) ''' robot.changeImage("Love.jpg") robot.playAudio("french.wav") time.sleep(5) #Connect to Misty, be sure to place your robots IP Address here robot = mistyPy.Robot("<PUT ROBOT IP ADDRESS HERE>") #Reset Misty's base pose and expression robot.moveHead(0,-5,0) robot.changeImage("Content.jpg") #Make sure your robot has this asset! #Subscribe to Facial Recognition robot.subscribe("FaceRecognition") #Watch for Data coming trhough Web Sockets prevData = None lastSentMessage = None #This loop will run and watch for facial recognition events until print("\n Ctrl+C to exit loop \n") while True:
imgdata = base64.b64decode(b64data) imgFile = open('./snapshot.jpg', 'wb') imgFile.write(imgdata) #Announce Text toAnnounce = "" for text in getTextFromImage( "./snapshot.jpg", "PUT COGNITIVE SERVICES VISION KEY HERE" ): #Cognitive Service Vision Service Subscription Key print("---------" + text) toAnnounce += text + " or " if len(toAnnounce) > 4: audioFilePath = tts.say_this(toAnnounce[0:-4]) contents = [] with open(audioFilePath, 'rb') as fd: contents = fd.read() byteArrayString = str(list(contents)) h = {'Content-Type': 'multipart/form-data'} # body = { 'FilenameWithoutPath': 'example.wav','DataAsByteArrayString': byteArrayString, 'ImmediatelyApply': False, 'OverwriteExisting': True } body = '{FilenameWithoutPath: tts.wav,DataAsByteArrayString: ' + byteArrayString + ', ImmediatelyApply: false, OverwriteExisting: true }' response = requests.post("http://10.0.10.69/api/audio", headers=h, data=body) response.raise_for_status() robot = mistyPy.Robot(mistyIPAddress) robot.playAudio("tts.wav")
""" Created on Sat Mar 9 20:36:49 2019 @author: Suchir """ import mistyPy # Imports misty's program import time # Imports time module to use the sleep command mia = mistyPy.Robot("192.168.0.17") # Connect's to misty mia.changeLED(0, 0, 255) #Set the LED to Blue to show start of the program time.sleep(30) # To show we can see the program has started mia.changeLED(0, 255, 0) # Change the led to green to signal ready state mia.subscribe("TimeOfFlight") # Subsribes to time of flight while True: # Start a infinite loop incoming_data = mia.time_of_flight( ) # Start reading the distance from all sensor's print(incoming_data) # Check the sensor's data distance = incoming_data["Center"] # Get the center's time of flight data print(distance) # Tell us how far the object is if distance < 0.080: #If distance is less than meter-20% mia.changeLED(255, 0, 0) #Change color to red as misty is blocked mia.unsubscribe("TimeOfFlight") # Unsubscribe break # Break from while loop mia.changeLED( 127, 255, 212) # In the end set to Aquamarine color to show program completion