Skip to content

Commit 87472d7

Browse files
committed
Fix Intent Detection Compiler Error
1 parent 0845ce5 commit 87472d7

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

ros/angel_system_nodes/angel_system_nodes/audio/intent/base_intent_detector.py

+16-15
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ def _tiebreak_intents(intents, confidences):
9595
)
9696
return classification, score
9797

98-
intent, score = self.detect_intents(msg)
9998
lower_utterance = msg.utterance_text.lower()
10099
intents = []
101100
confidences = []
@@ -108,37 +107,39 @@ def _tiebreak_intents(intents, confidences):
108107
if self._contains_phrase(lower_utterance, QUESTION_KEYPHRASES):
109108
intents.append(INTENT_LABELS[2])
110109
confidences.append(0.5)
110+
111111
if not intents:
112112
colored_utterance = colored(msg.utterance_text, "light_blue")
113-
self.log.info(f'No intents detected for:\n>>> "{colored_utterance}":')
113+
self.log.info(
114+
f'No intents detected for:\n>>> "{colored_utterance}":')
114115
return None, -1.0
116+
else:
117+
classification, confidence = _tiebreak_intents(intents, confidences)
118+
classification = colored(classification, "light_green")
119+
self.publish_message(msg.utterance_text, classification, confidence)
115120

116-
classification, confidence = _tiebreak_intents(intents, confidences)
117-
classification = colored(classification, "light_green")
118-
119-
if intent:
120-
self.publish_msg(msg.utterance_text, intent, score)
121-
122-
def publish_msg(self, msg: DialogueUtterance, intent: str, score: float):
121+
def publish_message(self, msg: DialogueUtterance, intent: str,
122+
score: float):
123123
"""
124124
Handles message publishing for an utterance with a detected intent.
125125
"""
126-
pub_msg = self.copy_dialogue_utterance(msg,
127-
node_name="Intent Detection",
128-
copy_time=self.get_clock().now().to_msg())
126+
pub_msg = self.copy_dialogue_utterance(
127+
msg, node_name="Intent Detection",
128+
copy_time=self.get_clock().now().to_msg())
129129
# Overwrite the user intent with the latest classification information.
130130
pub_msg.intent = intent
131131
pub_msg.intent_confidence_score = score
132132

133133
# Decide which intent topic to publish the message to.
134134
published_topic = None
135-
if self._contains_phrase(pub_msg.utterance_text.lower(), OVERRIDE_KEYPHRASES):
135+
if self._contains_phrase(pub_msg.utterance_text.lower(),
136+
OVERRIDE_KEYPHRASES):
137+
published_topic = PARAM_EXPECT_USER_INTENT_TOPIC
136138
pub_msg.intent_confidence_score = 1.0
137139
self._expected_publisher.publish(pub_msg)
138-
published_topic = PARAM_EXPECT_USER_INTENT_TOPIC
139140
else:
140-
self._interp_publisher.publish(pub_msg)
141141
published_topic = PARAM_INTERP_USER_INTENT_TOPIC
142+
self._interp_publisher.publish(pub_msg)
142143

143144
colored_utterance = colored(pub_msg.utterance_text, "light_blue")
144145
colored_intent = colored(pub_msg.intent, "light_green")

0 commit comments

Comments
 (0)