Changes between Version 34 and Version 35 of en/ProgrammingRobotsCourse/PepperApi
- Timestamp:
- Feb 16, 2022, 3:12:26 PM (2 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
en/ProgrammingRobotsCourse/PepperApi
v34 v35 12 12 * enter only one box `Python Script` 13 13 * edit its contents via double click: 14 * to ` __init__` add:14 * to `onLoad` add: 15 15 {{{#!python 16 16 self.tts = ALProxy('ALTextToSpeech') … … 28 28 29 29 === speech input via Python 30 * in ` __init__` add:30 * in `odLoad` add: 31 31 {{{#!python 32 self.dialog = ALProxy('ALDialog') 33 self.dialog.setLanguage('Czech') 34 self.mem = ALProxy('ALMemory') 32 35 try: 33 36 self.speech = ALProxy("ALSpeechRecognition") 34 37 self.speech.setLanguage('Czech') 38 self.logger.info('Running on real robot') 35 39 except: 36 40 self.logger.info('Running on virtual robot') … … 41 45 def get_answer(self, reactions): 42 46 if self.speech is None: 47 # random answer on virtual robot 43 48 return (random.choice(reactions.keys())) 44 49 else: 45 self.speech.setVocabulary(reactions.keys(), False) 50 try: 51 self.speech.setVocabulary(reactions.keys(), False) 52 except RuntimeError: # fix incorrectly reset dialog 53 self.logger.info('Reset language') 54 self.dialog.setLanguage('English') 55 self.onLoad() 56 self.speech.setVocabulary(reactions.keys(), False) 46 57 self.speech.subscribe("Test_ASR") 47 58 self.logger.info('Speech recognition engine started') 48 time.sleep(20) 59 while True: 60 word = self.mem.getData("WordRecognized") 61 if type(word) == list and word[0] != '': 62 break 49 63 self.speech.unsubscribe("Test_ASR") 64 return word[0] 50 65 51 66 def onInput_onStart(self): … … 62 77 self.onStopped() 63 78 }}} 64 * in case of error `ALSpeechRecognition::setVocabulary NuanceContext::addContext A grammar named "modifiable_grammar" already exists` just rerun the app once more. 79 * in case of error `ALSpeechRecognition::setVocabulary NuanceContext::addContext A grammar named "modifiable_grammar" already exists` just rerun the app once more. But this should be already solved by the included "''fix incorrectly reset dialog''". 65 80 * see [http://doc.aldebaran.com/2-5/naoqi/audio/alspeechrecognition.html ALSpeechRecognition] documentation 66 81