From f0320882154608ac11123575e207ea7b3371d053 Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Fri, 10 May 2024 11:44:44 -0700 Subject: [PATCH 1/2] Patch out file resolution error --- __init__.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/__init__.py b/__init__.py index 9185730..d9e2421 100644 --- a/__init__.py +++ b/__init__.py @@ -40,6 +40,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from os.path import join, isfile from ovos_workshop.decorators import fallback_handler from ovos_workshop.skills.fallback import FallbackSkill from neon_utils.message_utils import request_for_neon @@ -71,13 +72,21 @@ def _read_voc_lines(self, name) -> filter: :param name: vocab resource name :returns: filter for specified vocab resource """ - with open(self.find_resource(name + '.voc', 'vocab')) as f: + vocab = self.find_resource(f"{name}.voc", 'vocab', + lang=self.lang) + if self.lang not in vocab: + test_path = join(self.root_dir, "vocab", self.lang, f"{name}.voc") + if isfile(test_path): + LOG.warning(f"Resolved {vocab} but using {test_path}") + vocab = test_path + LOG.debug(f"Reading voc file {vocab} for lang={self.lang}") + with open(vocab) as f: return filter(bool, map(str.strip, f.read().split('\n'))) @fallback_handler(priority=100) def handle_fallback(self, message: Message): - LOG.info("Unknown Fallback Checking for Neon!!!") utterance = message.data['utterance'] + LOG.info(f"Unknown Fallback handling: {utterance}") client = message.context.get('client') ww_state = self.config_core.get("listener", {}).get("wake_word_enabled", True) @@ -110,12 +119,11 @@ def handle_fallback(self, message: Message): })) LOG.debug(f"Checking if neon must respond: {message.data}") - # Determine what kind of question this is to reply appropriately for i in ['question', 'who.is', 'why.is']: for line in self._read_voc_lines(i): if utterance.startswith(line): - LOG.info('Fallback type: ' + i) + LOG.info(f'Fallback type: {i} ({utterance})') self.speak_dialog(i, data={'remaining': line.replace(i, '')}) return True From c5d51eef003d95d77a17352af0b6e1be914e2fc7 Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Fri, 10 May 2024 12:05:41 -0700 Subject: [PATCH 2/2] Resolve test failure --- test/test_skill.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/test_skill.py b/test/test_skill.py index e9e2060..f383255 100644 --- a/test/test_skill.py +++ b/test/test_skill.py @@ -32,8 +32,7 @@ from os.path import dirname from mock import Mock -from mycroft_bus_client import Message -from neon_utils.skills import NeonFallbackSkill +from ovos_bus_client.message import Message from neon_minerva.tests.skill_unit_test_base import SkillTestCase