From 7bd906266f13854c24f1e7081b7c0f54505e4667 Mon Sep 17 00:00:00 2001 From: JarbasAI <33701864+JarbasAl@users.noreply.github.com> Date: Wed, 20 Nov 2024 10:02:28 +0000 Subject: [PATCH 1/3] feat:utterance_modifiers (#291) * feat:utterance_modifiers allow skills to access the utterance choosen by self.speak_dialog either to modify it (eg, pronounce numbers) or just to passively monitor it * feat:utterance_modifiers allow skills to access the utterance choosen by self.speak_dialog either to modify it (eg, pronounce numbers) or just to passively monitor it --- ovos_workshop/skills/ovos.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/ovos_workshop/skills/ovos.py b/ovos_workshop/skills/ovos.py index be9206d7..45d4f075 100644 --- a/ovos_workshop/skills/ovos.py +++ b/ovos_workshop/skills/ovos.py @@ -1664,7 +1664,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, + render_callback: Optional[Callable[[str, str], str]] = None): """ Speak a random sentence from a dialog file. @@ -1678,14 +1679,31 @@ def speak_dialog(self, key: str, data: Optional[dict] = None, wait (Union[bool, int]): set to True to block while the text is being spoken for 15 seconds. Alternatively, set to an integer to specify a timeout in seconds. + render_callback (Optional[Callable[[str, str], str]]): A callable + function that + transforms the + utterance before + it is spoken. + The function + should accept + the utterance + string and the + language as input + and return the + modified string. + Defaults to None. """ if self.dialog_renderer: data = data or {} + utterance = self.dialog_renderer.render(key, data) + if render_callback is not None: + utterance = render_callback(utterance, self.lang) 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?' ) From 56b1faf4544497683961d4aeb813f1ef6b620b35 Mon Sep 17 00:00:00 2001 From: JarbasAl Date: Wed, 20 Nov 2024 10:02:42 +0000 Subject: [PATCH 2/3] Increment Version to 3.1.0a1 --- ovos_workshop/version.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ovos_workshop/version.py b/ovos_workshop/version.py index b3ca9bcf..53aab068 100644 --- a/ovos_workshop/version.py +++ b/ovos_workshop/version.py @@ -1,6 +1,6 @@ # START_VERSION_BLOCK VERSION_MAJOR = 3 -VERSION_MINOR = 0 -VERSION_BUILD = 1 -VERSION_ALPHA = 0 +VERSION_MINOR = 1 +VERSION_BUILD = 0 +VERSION_ALPHA = 1 # END_VERSION_BLOCK From b39202ea317913cb215ffcd349afd5b870f18c7c Mon Sep 17 00:00:00 2001 From: JarbasAl Date: Wed, 20 Nov 2024 10:03:14 +0000 Subject: [PATCH 3/3] Update Changelog --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57c7ef3f..1a306a62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,12 @@ # Changelog -## [3.0.1a1](https://github.com/OpenVoiceOS/OVOS-workshop/tree/3.0.1a1) (2024-11-19) +## [3.1.0a1](https://github.com/OpenVoiceOS/OVOS-workshop/tree/3.1.0a1) (2024-11-20) -[Full Changelog](https://github.com/OpenVoiceOS/OVOS-workshop/compare/3.0.0...3.0.1a1) +[Full Changelog](https://github.com/OpenVoiceOS/OVOS-workshop/compare/3.0.1...3.1.0a1) **Merged pull requests:** -- fix:bundled\_resources [\#297](https://github.com/OpenVoiceOS/OVOS-workshop/pull/297) ([JarbasAl](https://github.com/JarbasAl)) +- feat:utterance\_modifiers [\#291](https://github.com/OpenVoiceOS/OVOS-workshop/pull/291) ([JarbasAl](https://github.com/JarbasAl))