class PlusMoins(pypot.primitive.Primitive): def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._move = "../src/moveRecorded/plus_moins.move" def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False num = random.randint(1,100) print (num) print "lancer plus, moins ou egal suivant la réponse du patient" with open(self._move) as f : m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(0.5) self._speak.start("Essaye de deviner à quel nombre je pense. Il est compris entre 1 et 100")
class Bonnard3(pypot.primitive.Primitive): def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._text = "Maintenant, voici le projet de reconnaissance biométrique de Jérôme" self._move = "../src/moveRecorded/bonnard3.move" def run(self): ### Geste poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f : m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(0.5) ### Son self._speak.start(self._text)
class PlusMoins(pypot.primitive.Primitive): def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._move = "../src/moveRecorded/plus_moins.move" def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False num = random.randint(1, 100) print(num) print "lancer plus, moins ou egal suivant la réponse du patient" with open(self._move) as f: m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(0.5) self._speak.start( "Essaye de deviner à quel nombre je pense. Il est compris entre 1 et 100" )
class Bonnard3(pypot.primitive.Primitive): def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._text = "Maintenant, voici le projet de reconnaissance biométrique de Jérôme" self._move = "../src/moveRecorded/bonnard3.move" def run(self): ### Geste poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f: m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(0.5) ### Son self._speak.start(self._text)
class Bonnard2(pypot.primitive.Primitive): def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._text = "Le projet suivant est celui d'Axel" self._move = "../src/moveRecorded/bonnard2.move" def run(self): ### Geste poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f: m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(1.5) ### Son self._speak.start(self._text)
class SayHello(pypot.primitive.Primitive): def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._name = 'Maximilien' self._move = "../src/moveRecorded/hello.move" def start(self, name): self._name = name pypot.primitive.Primitive.start(self) def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False text = "Bonjour, " + self._name + ". Comment vas tu aujourd'hui?" with open(self._move) as f : m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(1.5) self._speak.start(text)
class Bonnard4(pypot.primitive.Primitive): def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._text = "Enfin, je suis le projet tchéri. Je suis actuellement en développement. Je laisse mes concepteurs t'en parler." self._move = "../src/moveRecorded/bonnard4.move" def run(self): ### Geste poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f : m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(0.2) ### Son self._speak.start(self._text)
class SayHello(pypot.primitive.Primitive): def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._name = 'Maximilien' self._move = "../src/moveRecorded/hello.move" def start(self, name): self._name = name pypot.primitive.Primitive.start(self) def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False text = "Bonjour, " + self._name + ". Comment vas tu aujourd'hui?" with open(self._move) as f: m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(1.5) self._speak.start(text)
class Bonnard5(pypot.primitive.Primitive): def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._text = "Je n'ai pas pu venir te rencontrer à Paris pour la cérémonie. A propos, ai-je le droit à une médaille?" self._move = "../src/moveRecorded/bonnard5.move" def run(self): ### Geste poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f : m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(0.5) ### Son self._speak.start(self._text)
class Bonnard1(pypot.primitive.Primitive): def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._text = "Bonjour Christophe. Bienvenue au pôle innovation. Nous allons te présenter nos différents projets en cours. Commençons par Yvon, qui va te présenter le projet Octobre Bleu." self._move = "../src/moveRecorded/bonnard1.move" def run(self): ### Geste poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f: m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(0) ### Son self._speak.start(self._text)
class Vrai4(pypot.primitive.Primitive): def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._move = "../src/moveRecorded/vrai1.move" def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f : m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(1.5) self._speak.start("Bravo! Tu as vu comme je suis bon acteur?")
class Bonnard1(pypot.primitive.Primitive): def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._text = "Bonjour Christophe. Bienvenue au pôle innovation. Nous allons te présenter nos différents projets en cours. Commençons par Yvon, qui va te présenter le projet Octobre Bleu." self._move = "../src/moveRecorded/bonnard1.move" def run(self): ### Geste poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f : m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(0) ### Son self._speak.start(self._text)
class Plus(pypot.primitive.Primitive): def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._move = "../src/moveRecorded/faux.move" def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f : m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(1.5) self._speak.start("Hé non, mon nombre est plus grand. Essaye encore!")
class Bonnard5(pypot.primitive.Primitive): def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._text = "Je n'ai pas pu venir te rencontrer à Paris pour la cérémonie. A propos, ai-je le droit à une médaille?" self._move = "../src/moveRecorded/bonnard5.move" def run(self): ### Geste poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f: m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(0.5) ### Son self._speak.start(self._text)
class Bonnard2(pypot.primitive.Primitive): def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._text = "Le projet suivant est celui d'Axel" self._move = "../src/moveRecorded/bonnard2.move" def run(self): ### Geste poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f : m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(1.5) ### Son self._speak.start(self._text)
class Bonnard6(pypot.primitive.Primitive): def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._text = "Si quelque chose ne va pas, n'hésite pas à me le dire, et j'appellerai les infirmières." self._move = "../src/moveRecorded/bonnard6.move" def run(self): ### Geste poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f: m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(0.5) ### Son self._speak.start(self._text)
class Egal(pypot.primitive.Primitive): def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._move = "../src/moveRecorded/vrai1.move" def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f : m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(1.5) self._speak.start("Bien joué! On croirait presque que tu lis dans mes électrons!")
class Faux(pypot.primitive.Primitive): def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._move = "../src/moveRecorded/faux.move" def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f : m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(2) self._speak.start("Non, ce n'est pas ça. Essaye encore!")
class Bonnard6(pypot.primitive.Primitive): def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._text = "Si quelque chose ne va pas, n'hésite pas à me le dire, et j'appellerai les infirmières." self._move = "../src/moveRecorded/bonnard6.move" def run(self): ### Geste poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f : m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(0.5) ### Son self._speak.start(self._text)
class Bonnard4(pypot.primitive.Primitive): def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._text = "Enfin, je suis le projet tchéri. Je suis actuellement en développement. Je laisse mes concepteurs t'en parler." self._move = "../src/moveRecorded/bonnard4.move" def run(self): ### Geste poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f: m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(0.2) ### Son self._speak.start(self._text)
class Sara: def __init__(self): # Initializing speech recognition engine self.speech_recognition_object = RecognizeSpeech() # Initializing TTS engine self.speak_object = Speak() def listen(self): """ This function returns decoded speech :return: (str) speech : The decoded speech. """ speech = self.speech_recognition_object.recognize_speech() return speech def speak(self, text): """ Converts text to speech and speaks aloud :param text: The text to speak. """ self.speak_object.speak(text) def get_time(self): """ :return: (str) Current time in 12 hour format. """ time = datetime.now() if time.hour < 12: time = (str)(time.hour) + ":" + (str)(time.minute) + " AM" else: time = (str)(time.hour) + ":" + (str)(time.minute) + " PM" return time def generate_greetings(self): """ Generates greetings based upon time. :return: (str) Greetings. """ greetings = "Good " time = datetime.now() if time.hour >= 0 and time.hour < 12: greetings = greetings + "Morning" elif time.hour >= 12 and time.hour < 18: greetings = greetings + "Afternoon" elif time.hour >= 18 and time.hour <= 24: greetings = greetings + "Night" return greetings def introduction(self): """ :return: (str) Introduction speech with greetings. """ text = "Hi, " + self.generate_greetings() + "." text = text + " I am Sara, and how can I help you?\n" return text
def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._move = "../src/moveRecorded/mime.move" self._movem1 = "../src/moveRecorded/singe.move" self._movem2 = "../src/moveRecorded/poulet.move" self._movem3 = "../src/moveRecorded/nager.move" self._movem4 = "../src/moveRecorded/manger.move"
def main(): global g_interrupted g_interrupted = True while g_interrupted: g_interrupted = False speak_action = Speak(150, 50, "please don't interrupt me i really want to finish" \ "this sentence okay good it worked") speak_action.OnInterrupt(on_interrupt) ActionProcess('speak_action_process', speak_action).Run()
def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._saytext = SayText(robot) self._move = "../src/moveRecorded/arrivee.move" self._move2 = "../src/moveRecorded/arrive_tete.move"
def run(self): # Daten vom Client empfangen damit Funktionen gestartet werden können try: self.dataFromClient = self.komm_handy.kommunikationHandy(5000) try: while True: self.data= self.dataFromClient.recv(1024).decode("utf-8") #Abfrage ob noch Kommandos kommen, wenn nicht dann wird erneut nach dem Aufbau der Verbindung gefragt. Wird nur hier getan und nicht in handyWheels if not (self.data): print("End transmit commands") self.komm_handy.kommunikationHandyClose() self.dataFromClient = self.komm_handy.kommunikationHandy(5000) cmdList = self.data.split("\n") cmdList=cmdList[:-1] for oneCmd in cmdList: # comma, or other dataSplit=oneCmd.split("#") if (len(dataSplit) == 3) and (dataSplit[0] == "CMD_SERVO"): print(dataSplit) if ((dataSplit[1] == "0") and (int(dataSplit[2])>int(self.verglRichtung1))): print("motor1, rechts wird übergeben") self.komm_handy.kommunikationArduino("b") #Motor1 wird rechts gedreht Speak().voice("Kamera links") self.verglRichtung1 = dataSplit[2] elif ((dataSplit[1] == "0") and (int(dataSplit[2])<int(self.verglRichtung1))): print("motor1, links wird übergeben") self.komm_handy.kommunikationArduino("a") #Motor1 wird links gedreht Speak().voice("Kamera rechts") self.verglRichtung1 = dataSplit[2] elif ((dataSplit[1] == "1") and (int(dataSplit[2])>int(self.verglRichtung2))): print("motor2, hoch wird übergeben") self.komm_handy.kommunikationArduino("c") #Motor2 wird hoch gedreht Speak().voice("Kamera hoch") self.verglRichtung2 = dataSplit[2] elif ((dataSplit[1] == "1") and (int(dataSplit[2])<int(self.verglRichtung2))): print("motor2, runter wird übergeben") self.komm_handy.kommunikationArduino("d") #Motor2 wird runter gedreht Speak().voice("Kamera runter") self.verglRichtung2 = dataSplit[2] except Exception as e: print(e) self.komm_handy.kommunikationHandyClose() print("Programm Handy Steuerung geschlossen") except Exception as e: print(e) self.komm_handy.kommunikationHandyClose() pass
def __init__(self): Thread.__init__(self) self.recognizer = sr.Recognizer() self.microphone = sr.Microphone(device_index=2) self.text = "" self.kommunikation_arduino = CommunicationExtern() self.sprechen = Speak() self.daemon = True self.start()
def openCallWindow(self, topWindow): print "open call window" self.topWindow = topWindow self.frame = tk.Frame(topWindow) self.frame.grid() speak = Speak.Speak() speak.sayIntroduction() cameraIndex = 0 cameraIndex2 = 2 # RecordAndPlay.recordAndPlay() self.startVideo(cameraIndex, cameraIndex2) self.callFaceTracker(cameraIndex2)
class Faux(pypot.primitive.Primitive): def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._move = "../src/moveRecorded/faux.move" def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f: m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(2) self._speak.start("Non, ce n'est pas ça. Essaye encore!")
class Vrai2(pypot.primitive.Primitive): def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._move = "../src/moveRecorded/vrai1.move" def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f: m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(1.5) self._speak.start("Bravo! Eh oui je suis un robot.")
class Egal(pypot.primitive.Primitive): def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._move = "../src/moveRecorded/vrai1.move" def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f: m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(1.5) self._speak.start( "Bien joué! On croirait presque que tu lis dans mes électrons!")
def Task(self): comments = [ "You are a good teacher", "You look nice today", "I like bananas", "My name is Gemini"] time.sleep(self.wait_time_) ActionProcess('', LookCenter()).Run() time.sleep(self.wait_time_) ActionProcess('', Nod()).Run() random_comment = random.randint(0,len(comments) - 1) ActionProcess('', Speak(150, 50, comments[random_comment])).Run() time.sleep(self.wait_time_) ActionProcess('', Nod()).Run()
def initiateSequence(self): # # Boolean variable that will represent # # whether or not the arduino is connected self.connected = False # # open the serial port that your ardiono # # is connected to. self.ser = serial.Serial("COM8", 9600) # # loop until the arduino tells us it is ready while not self.connected: serin = self.ser.read() self.connected = True print "connecting" self.sensorValues = np.array( [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) self.speak = Speak.Speak() self.speak.sayIntroduction()
def initiateSequence(self): # # Boolean variable that will represent # # whether or not the arduino is connected self.connected = False # # open the serial port that your ardiono # # is connected to. self.ser = serial.Serial("COM8", 9600) time.sleep(2) # send 0 for ready self.ser.write("0") # # loop until the arduino tells us it is ready while not self.connected: print "connecting" serin = self.ser.read() if serin != -1 and int(serin) == 1: self.connected = True print "connected" self.isSendOver = True self.isReceiveOver = True self.canSendStart = False self.sendIndex = -1 self.receiveIndex = -1 self.controlCode = -1 self.componentId = -1 self.data = -1 self.sensorCount = -1 self.actuatorCount = -1 self.sensorValues = np.array( [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) self.actuatorValues = np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) self.speedValues = np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) self.speak = Speak.Speak() self.speak.sayIntroduction() print "starting"
def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._text = "Le projet suivant est celui d'Axel" self._move = "../src/moveRecorded/bonnard2.move"
class Mime(pypot.primitive.Primitive): def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._move = "../src/moveRecorded/mime.move" self._movem1 = "../src/moveRecorded/singe.move" self._movem2 = "../src/moveRecorded/poulet.move" self._movem3 = "../src/moveRecorded/nager.move" self._movem4 = "../src/moveRecorded/manger.move" # self._moveo = "../src/moveRecorded/faux.move" # self._moven = "../src/moveRecorded/vrai4.move" def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False num1 = random.randint(1, 4) if num1 == 1: text1 = "singe" mouvement = self._movem1 elif num1 == 2: text1 = "poulet" mouvement = self._movem2 elif num1 == 3: text1 = "nager" mouvement = self._movem3 elif num1 == 4: text1 = "manger" mouvement = self._movem4 else: text1 = "singe" mouvement = self._movem1 print (text1) print "lancer vrai4 si le patient répond bien, faux si il se trompe." text = "Devine ce que je mime." with open(self._move) as f: m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(0.5) self._speak.start(text) time.sleep(3) with open(mouvement) as f: m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start()
def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._text = "Si quelque chose ne va pas, n'hésite pas à me le dire, et j'appellerai les infirmières." self._move = "../src/moveRecorded/bonnard6.move"
def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._text = "Je n'ai pas pu venir te rencontrer à Paris pour la cérémonie. A propos, ai-je le droit à une médaille?" self._move = "../src/moveRecorded/bonnard5.move"
def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._text = "Enfin, je suis le projet tchéri. Je suis actuellement en développement. Je laisse mes concepteurs t'en parler." self._move = "../src/moveRecorded/bonnard4.move"
def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._text = "Bonjour Christophe. Bienvenue au pôle innovation. Nous allons te présenter nos différents projets en cours. Commençons par Yvon, qui va te présenter le projet Octobre Bleu." self._move = "../src/moveRecorded/bonnard1.move"
def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._move = "../src/moveRecorded/vrai1.move"
class Dictee(pypot.primitive.Primitive): def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._move = "../src/moveRecorded/dictee.move" def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False num1 = random.randint(1,10) if num1 == 1 : text1 = "Cherry" elif num1 == 2 : text1 = "papillon" elif num1 == 3 : text1 = "maison" elif num1 == 4: text1 = "arbre" elif num1 == 5: text1 = "feuille" elif num1 == 6: text1 = "école" elif num1 == 7: text1 = "hôpital" elif num1 == 8: text1 = "lit" elif num1 == 9: text1 = "table" elif num1 == 10: text1 = "éléphant" else: text1 = "Cherry" print (text1) print "alancer vrai3 si le patient répond bien, faux si il se trompe." text = "Dis moi comment on écrit " + text1 + "." with open(self._move) as f : m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(1) self._speak.start(text) # while True : # rep = raw_input() # #if appuie sur n # if rep == "n" : # with open(self._moven) as f : # m = Move.load(f) # move_player = MovePlayer(self.robot, m) # move_player.start() # time.sleep(1.5) # self._speak.start("Non, ce n'est pas ça. Essaye encore!") # elif rep == "o" : # with open(self._moveo) as f : # m = Move.load(f) # move_player = MovePlayer(self.robot, m) # move_player.start() # time.sleep(1.5) # self._speak.start("Bravo! Tu t'y connais en orthographe!") # break
def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._text = "Maintenant, voici le projet de reconnaissance biométrique de Jérôme" self._move = "../src/moveRecorded/bonnard3.move"
def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._name = 'Maximilien' self._move = "../src/moveRecorded/hello.move"
class Charade(pypot.primitive.Primitive): def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._move = "../src/moveRecorded/charade.move" def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False print "robot" print "lancer vrai2 si le patient répond bien, faux si il se trompe." with open(self._move) as f : m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(1.5) self._speak.start("J'ai une charade pour toi. Mon premier est un bruit malpoli. Mon deuxième est très joli. Mon tout est ce que je suis. Qui suis-je?") #while pas appuie sur o # while True : # rep = raw_input() # #if appuie sur n # if rep == "n" : # with open(self._moven) as f : # m = Move.load(f) # move_player = MovePlayer(self.robot, m) # move_player.start() # time.sleep(1.5) # self._speak.start("Non, ce n'est pas ça. Essaye encore!") # #if appuie sur r # elif rep == "r" : # with open(self._mover) as f : # m = Move.load(f) # move_player = MovePlayer(self.robot, m) # move_player.start() # time.sleep(1.5) # self._speak.start("D'accord, je te répète la charade.") # with open(self._move) as f : # m = Move.load(f) # move_player = MovePlayer(self.robot, m) # move_player.start() # time.sleep(1.5) # self._speak.start("Mon premier est un bruit malpoli. Mon deuxième est très joli. Mon tout est ce que je suis!") # #sortie while # elif rep == "o" : # with open(self._moveo) as f : # m = Move.load(f) # move_player = MovePlayer(self.robot, m) # move_player.start() # time.sleep(1.5) # self._speak.start("Bravo! C'est bien Robot!") # break
class MultipRand(pypot.primitive.Primitive): def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._move = "../src/moveRecorded/multip.move" def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False num1 = random.randint(1, 10) num2 = random.randint(1, 10) sol = num2 * num1 if num1 == 1: text1 = "un" elif num1 == 2: text1 = "deux" elif num1 == 3: text1 = "trois" elif num1 == 4: text1 = "quatre" elif num1 == 5: text1 = "cinq" elif num1 == 6: text1 = "six" elif num1 == 7: text1 = "sept" elif num1 == 8: text1 = "huit" elif num1 == 9: text1 = "neuf" elif num1 == 10: text1 = "dix" else: text1 = "un" if num2 == 1: text2 = "un" elif num2 == 2: text2 = "deux" elif num2 == 3: text2 = "trois" elif num2 == 4: text2 = "quatre" elif num2 == 5: text2 = "cinq" elif num2 == 6: text2 = "six" elif num2 == 7: text2 = "sept" elif num2 == 8: text2 = "huit" elif num2 == 9: text2 = "neuf" elif num2 == 10: text2 = "dix" else: text2 = "un" print(sol) print "Lancer vrai1 si le patient répond bien, faux il se trompe." text = "Dis moi, combien font " + text1 + "fois " + text2 + "?" with open(self._move) as f: m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(0.5) self._speak.start(text)
class MultipRand(pypot.primitive.Primitive): def __init__(self, robot): pypot.primitive.Primitive.__init__(self, robot) self._speak = Speak(robot) self._move = "../src/moveRecorded/multip.move" def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False num1 = random.randint(1,10) num2 = random.randint(1,10) sol = num2*num1 if num1 == 1 : text1 = "un" elif num1 == 2 : text1 = "deux" elif num1 == 3 : text1 = "trois" elif num1 == 4: text1 = "quatre" elif num1 == 5: text1 = "cinq" elif num1 == 6: text1 = "six" elif num1 == 7: text1 = "sept" elif num1 == 8: text1 = "huit" elif num1 == 9: text1 = "neuf" elif num1 == 10: text1 = "dix" else: text1 = "un" if num2 == 1: text2 = "un" elif num2 == 2: text2 = "deux" elif num2 == 3: text2 = "trois" elif num2 == 4: text2 = "quatre" elif num2 == 5: text2 = "cinq" elif num2 == 6: text2 = "six" elif num2 == 7: text2 = "sept" elif num2 == 8: text2 = "huit" elif num2 == 9: text2 = "neuf" elif num2 == 10: text2 = "dix" else: text2 = "un" print (sol) print "Lancer vrai1 si le patient répond bien, faux il se trompe." text = "Dis moi, combien font " + text1 + "fois " + text2 + "?" with open(self._move) as f : m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(0.5) self._speak.start(text)