예제 #1
0
    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)
예제 #2
0
    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)
예제 #3
0
    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)
예제 #4
0
    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)