def run(self): """Publishing usersaid when grammar is enabled """ # TODO: add tags, add other fields, take into account loaded grammar to put other text in the recognized sentence while not rospy.is_shutdown(): if self.enabled_asr and self.enabled_grammar: #Check for a new sentence if self.isData(): MOCK_SAID = sys.stdin.readline() recognized_sentence = ASREvent() recognized_sentence.recognized_utterance.text = MOCK_SAID[:len(MOCK_SAID)-1:] recognized_sentence.recognized_utterance.confidence = recognized_sentence.recognized_utterance.CONFIDENCE_MAX recognized_sentence.event_id=2 # Tags from file with open(self.fileName) as myfile: for line in myfile: name, var = line.partition("=")[::2] tag = actiontag() tag.key = name tag.value = var[:len(var)-1:] recognized_sentence.recognized_utterance.tags.append(tag); recognized_sentence.active = self.enabled_asr self.usersaid_pub.publish(recognized_sentence) rospy.sleep(1)
def run(self): """Publishing usersaid when grammar is enabled """ # TODO: add tags, add other fields, take into account loaded grammar to put other text in the recognized sentence while not rospy.is_shutdown(): if self.enabled_asr and self.enabled_grammar: #Check for a new sentence if True: print "Write text that was recognized:" MOCK_SAID = sys.stdin.readline() recognized_sentence = ASREvent() recognized_sentence.recognized_utterance.text = MOCK_SAID[:len(MOCK_SAID)-1:] recognized_sentence.recognized_utterance.confidence = recognized_sentence.recognized_utterance.CONFIDENCE_MAX recognized_sentence.event_id=2 exit = False print "Write '.' to exit tag adding" while not exit: print "Write tag:" read = sys.stdin.readline() if "." in read: exit = True break tag = actiontag() tag.key = read print "Write value of tag:" tag.value = sys.stdin.readline() recognized_sentence.recognized_utterance.tags.append(tag) recognized_sentence.active = self.enabled_asr self.usersaid_pub.publish(recognized_sentence) rospy.sleep(1)
def run(self): """Publishing usersaid when grammar is enabled """ # TODO: add tags, add other fields, take into account loaded grammar to put other text in the recognized sentence while not rospy.is_shutdown(): if self.enabled_asr and self.enabled_grammar: #Check for a new sentence if self.isData(): MOCK_SAID = sys.stdin.readline() recognized_sentence = ASREvent() recognized_sentence.recognized_utterance.text = MOCK_SAID[:len( MOCK_SAID) - 1:] recognized_sentence.recognized_utterance.confidence = recognized_sentence.recognized_utterance.CONFIDENCE_MAX recognized_sentence.event_id = 2 # Tags from file with open(self.fileName) as myfile: for line in myfile: name, var = line.partition("=")[::2] tag = actiontag() tag.key = name tag.value = var[:len(var) - 1:] recognized_sentence.recognized_utterance.tags.append( tag) recognized_sentence.active = self.enabled_asr self.usersaid_pub.publish(recognized_sentence) rospy.sleep(1)
def run(self): """Publishing usersaid when grammar is enabled """ # TODO: add tags, add other fields, take into account loaded grammar to put other text in the recognized sentence while not rospy.is_shutdown(): if self.enabled_asr and self.enabled_grammar: #Check for a new sentence if True: print "Write text that was recognized:" MOCK_SAID = sys.stdin.readline() recognized_sentence = ASREvent() recognized_sentence.recognized_utterance.text = MOCK_SAID[:len( MOCK_SAID) - 1:] recognized_sentence.recognized_utterance.confidence = recognized_sentence.recognized_utterance.CONFIDENCE_MAX recognized_sentence.event_id = 2 exit = False print "Write '.' to exit tag adding" while not exit: print "Write tag:" read = sys.stdin.readline() if "." in read: exit = True break tag = actiontag() tag.key = read print "Write value of tag:" tag.value = sys.stdin.readline() recognized_sentence.recognized_utterance.tags.append( tag) recognized_sentence.active = self.enabled_asr self.usersaid_pub.publish(recognized_sentence) rospy.sleep(1)
def execute(self, userdata): self.time_init = rospy.get_rostime() self.msg_data = ASREvent() self.subs = rospy.Subscriber(topic_name, ASREvent, self.callback_topic) while not self.msg_data.event_id == ASREvent.EVENT_RECOGNIZED_UTT and ( rospy.get_rostime().secs - self.time_init.secs) < self.topic_time_out: rospy.sleep(0.3) if self.preempt_requested(): return 'preempted' self.subs.unregister() if self.msg_data.event_id == ASREvent.EVENT_RECOGNIZED_UTT: userdata.topic_output_msg = copy.deepcopy(self.msg_data) userdata.standard_error = '' return 'succeeded' else: #time out userdata.standard_error = "Topic Reader : TimeOut Error" userdata.topic_output_msg = '' return 'aborted'