From 6233ec7cd88e2a47af50bfbf61ed97dea65ea4c2 Mon Sep 17 00:00:00 2001 From: JarbasAi Date: Mon, 9 Oct 2023 01:37:30 +0100 Subject: [PATCH 1/2] feat/skip_skills_in_dialog_transform allow some skills to explicitly skip the dialog transformers by default jokes skill is blacklisted ``` "dialog_transformers": { "blacklisted_skills": ["skill-ovos-icanhazdadjokes.openvoiceos"] } ``` --- ovos_audio/service.py | 8 +++++--- ovos_audio/transformers.py | 7 +++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ovos_audio/service.py b/ovos_audio/service.py index c21fdc2..86b0c5a 100644 --- a/ovos_audio/service.py +++ b/ovos_audio/service.py @@ -278,9 +278,11 @@ def handle_speak(self, message): utterance = message.data['utterance'] # allow dialog transformers to rewrite speech - utt2, message.context = self.dialog_transform.transform(dialog=utterance, - context=message.context, - sess=sess) + skill_id = message.data.get("meta", {}).get("skill") or message.context.get("skill_id") + if skill_id and skill_id not in self.dialog_transform.blacklisted_skills: + utt2, message.context = self.dialog_transform.transform(dialog=utterance, + context=message.context, + sess=sess) if utterance != utt2: LOG.debug(f"original dialog: {utterance}") LOG.info(f"dialog transformed to: {utt2}") diff --git a/ovos_audio/transformers.py b/ovos_audio/transformers.py index 47a82ce..3c745ef 100644 --- a/ovos_audio/transformers.py +++ b/ovos_audio/transformers.py @@ -16,6 +16,13 @@ def __init__(self, bus, config=None): self.config = config or Configuration().get("dialog_transformers", {}) self.load_plugins() + @property + def blacklisted_skills(self): + # dialog should NEVER be rewritten if it comes from these skills + return self.config.get("blacklisted_skills", + ["skill-ovos-icanhazdadjokes.openvoiceos"] # blacklist jokes by default + ) + def load_plugins(self): for plug_name, plug in find_dialog_transformer_plugins().items(): if plug_name in self.config: From 366ba80b7ee372e49b135ef0968ffdaf3244c39a Mon Sep 17 00:00:00 2001 From: JarbasAi Date: Mon, 9 Oct 2023 02:56:56 +0100 Subject: [PATCH 2/2] fix indentation --- ovos_audio/service.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ovos_audio/service.py b/ovos_audio/service.py index 86b0c5a..9fb18d6 100644 --- a/ovos_audio/service.py +++ b/ovos_audio/service.py @@ -283,10 +283,10 @@ def handle_speak(self, message): utt2, message.context = self.dialog_transform.transform(dialog=utterance, context=message.context, sess=sess) - if utterance != utt2: - LOG.debug(f"original dialog: {utterance}") - LOG.info(f"dialog transformed to: {utt2}") - utterance = utt2 + if utterance != utt2: + LOG.debug(f"original dialog: {utterance}") + LOG.info(f"dialog transformed to: {utt2}") + utterance = utt2 listen = message.data.get('expect_response', False) self.execute_tts(utterance, sess.session_id, listen, message)