= [[https://is.muni.cz/auth/predmet/fi/pv277|PV277 Programming Applications for Social Robots]] (autumn 2019) = == Pepper API * http://doc.aldebaran.com/2-5/index_dev_guide.html * programming in Choregraphe via Python: * enter only one box `Python Script` * edit its contents via double click: * to `__init__` add: {{{#!python self.tts = ALProxy('ALTextToSpeech') self.tts.setLanguage('Czech') }}} * to `onInput_onStart` add: {{{#!python self.tts.say("Ahoj, jak se máš?") self.onStopped() }}} * add `Czech` into Project Properties [[br]] [[Image(pepper_project_cz.png)]] * save the project and run in on a virtual robot * speech input via Python: * in `__init__` add: {{{#!python try: self.speech = ALProxy("ALSpeechRecognition") self.speech.setLanguage('Czech') except: self.logger.info('Running on virtual robot') self.speech = None }}} * process speech accordingly {{{#!python def get_answer(self, reactions): if self.speech is None: return (random.choice(reactions.keys())) else: self.speech.setVocabulary(reactions.keys(), False) self.speech.subscribe("Test_ASR") self.logger.info('Speech recognition engine started') time.sleep(20) self.speech.unsubscribe("Test_ASR") def onInput_onStart(self): self.tts.say("Ahoj, jak se máš?") reactions = { 'dobře': 'to je super!', 'špatně': 'doufám, že to brzo bude lepší', 'nevím': 'tak to určitě nebude tak zlé', } answer = self.get_answer(reactions) react = reactions.get(answer) self.logger.info('answer={}, react={}'.format(answer, react)) self.tts.say(react) self.onStopped() }}}