Skip to content

Commit

Permalink
fix/missing dialogs in get_response method (#5) + (#43)
Browse files Browse the repository at this point in the history
- fix/get_response accept strings (#5)
- fix get_response default_fail dialog missing (#43)

there was a unnecessary check for self.dialog_renderer that was throwing an error unless a .dialog file existed, this PR allows direct usage of get_response method with strings to be spoken
  • Loading branch information
JarbasAl committed Aug 30, 2021
1 parent 7fdbbcd commit 8666b68
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions mycroft/skills/mycroft_skill/mycroft_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,9 +483,13 @@ def on_fail_default(utterance):
fail_data = data.copy()
fail_data['utterance'] = utterance
if on_fail:
return self.dialog_renderer.render(on_fail, fail_data)
if self.dialog_renderer:
return self.dialog_renderer.render(on_fail, fail_data)
return on_fail
else:
return self.dialog_renderer.render(dialog, data)
if self.dialog_renderer:
return self.dialog_renderer.render(dialog, data)
return dialog

def is_cancel(utterance):
return self.voc_match(utterance, 'cancel')
Expand All @@ -498,8 +502,7 @@ def validator_default(utterance):
validator = validator or validator_default

# Speak query and wait for user response
dialog_exists = self.dialog_renderer.render(dialog, data)
if dialog_exists:
if dialog:
self.speak_dialog(dialog, data, expect_response=True, wait=True)
else:
self.bus.emit(Message('mycroft.mic.listen'))
Expand Down Expand Up @@ -769,6 +772,8 @@ def translate(self, text, data=None):
Returns:
str: A randomly chosen string from the file
"""
if self.dialog_renderer is None:
return ""
return self.dialog_renderer.render(text, data or {})

def find_resource(self, res_name, res_dirname=None):
Expand Down

0 comments on commit 8666b68

Please sign in to comment.