Skip to content

Commit

Permalink
feat:utterance_modifiers
Browse files Browse the repository at this point in the history
allow skills to access the utterance choosen by self.speak_dialog

either to modify it (eg, pronounce numbers) or just to passively monitor it
  • Loading branch information
JarbasAl committed Nov 15, 2024
1 parent 1478f04 commit 7378680
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ovos_workshop/skills/ovos.py
Original file line number Diff line number Diff line change
Expand Up @@ -1696,7 +1696,8 @@ def speak(self, utterance: str, expect_response: bool = False,
SessionManager.wait_while_speaking(timeout, sess)

def speak_dialog(self, key: str, data: Optional[dict] = None,
expect_response: bool = False, wait: Union[bool, int] = False):
expect_response: bool = False, wait: Union[bool, int] = False,
prerender_transform: Optional[Callable] = None):
"""
Speak a random sentence from a dialog file.
Expand All @@ -1713,11 +1714,15 @@ def speak_dialog(self, key: str, data: Optional[dict] = None,
"""
if self.dialog_renderer:
data = data or {}
utterance = self.dialog_renderer.render(key, data)
if prerender_transform is not None:
utterance = prerender_transform(utterance)
self.speak(
self.dialog_renderer.render(key, data),
utterance,
expect_response, wait, meta={'dialog': key, 'data': data}
)
else:
# TODO - change this behaviour, speaking the dialog file name isn't that helpful!
self.log.error(
'dialog_render is None, does the locale/dialog folder exist?'
)
Expand Down

0 comments on commit 7378680

Please sign in to comment.