From 84d510e5b3dd9484b8c0d9770c104d000ce831d0 Mon Sep 17 00:00:00 2001 From: JarbasAI <33701864+JarbasAl@users.noreply.github.com> Date: Mon, 9 Oct 2023 03:06:04 +0100 Subject: [PATCH] feat/skip_skills_in_dialog_transform (#30) --- ovos_audio/service.py | 16 +++++++++------- ovos_audio/transformers.py | 7 +++++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ovos_audio/service.py b/ovos_audio/service.py index c21fdc2..9fb18d6 100644 --- a/ovos_audio/service.py +++ b/ovos_audio/service.py @@ -278,13 +278,15 @@ 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) - if utterance != utt2: - LOG.debug(f"original dialog: {utterance}") - LOG.info(f"dialog transformed to: {utt2}") - utterance = utt2 + 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}") + utterance = utt2 listen = message.data.get('expect_response', False) self.execute_tts(utterance, sess.session_id, listen, message) 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: