Add meta information about the speech dialog
Provides meta data such as dialog used and data that was inserted.
@@ -392,9 +392,9 @@ class MycroftSkill:
validator = validator or validator_default
# Speak query and wait for user response
- utterance = self.dialog_renderer.render(dialog, data)
- if utterance:
- self.speak(utterance, expect_response=True, wait=True)
+ dialog_exists = self.dialog_renderer.render(dialog, data)
+ if dialog_exists:
+ self.speak_dialog(dialog, data, expect_response=True, wait=True)
else:
self.bus.emit(Message('mycroft.mic.listen'))
return self._wait_response(is_cancel, validator, on_fail_fn,
@@ -1058,7 +1058,7 @@ class MycroftSkill:
re.compile(regex) # validate regex
self.intent_service.register_adapt_regex(regex)
- def speak(self, utterance, expect_response=False, wait=False):
+ def speak(self, utterance, expect_response=False, wait=False, meta=None):
"""Speak a sentence.
Arguments:
@@ -1068,11 +1068,13 @@ class MycroftSkill:
speaking the utterance.
wait (bool): set to True to block while the text
is being spoken.
+ meta: Information of what built the sentence.
"""
# registers the skill as being active
self.enclosure.register(self.name)
data = {'utterance': utterance,
- 'expect_response': expect_response}
+ 'expect_response': expect_response,
+ 'meta': meta or {}}
message = dig_for_message()
m = message.forward("speak", data) if message \
else Message("speak", data)
@@ -1096,7 +1098,7 @@ class MycroftSkill:
"""
data = data or {}
self.speak(self.dialog_renderer.render(key, data),
- expect_response, wait)
+ expect_response, wait, meta={'dialog': key, 'data': data})
def acknowledge(self):
"""Acknowledge a successful request.
