From 8e947fcd47acdf2d35650b7f6828e321c69f5735 Mon Sep 17 00:00:00 2001 From: JarbasAI <33701864+JarbasAl@users.noreply.github.com> Date: Thu, 7 Dec 2023 17:20:52 +0000 Subject: [PATCH] fix lang detect (#379) * fix lang detect fix ``` ovos-core-86bc9bc566-vjn5j ovos-core 2023-12-07 16:54:08.030 - skills - ovos_core.intent_services:handle_utterance:343 - ERROR - 'Session' object has no attribute 'valid_languages' ovos-core-86bc9bc566-vjn5j ovos-core Traceback (most recent call last): ovos-core-86bc9bc566-vjn5j ovos-core File "/home/ovos/.venv/lib/python3.11/site-packages/ovos_core/intent_services/__init__.py", line 289, in handle_utterance ovos-core-86bc9bc566-vjn5j ovos-core lang = self.disambiguate_lang(message) ovos-core-86bc9bc566-vjn5j ovos-core ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ovos-core-86bc9bc566-vjn5j ovos-core File "/home/ovos/.venv/lib/python3.11/site-packages/ovos_core/intent_services/__init__.py", line 191, in disambiguate_lang ovos-core-86bc9bc566-vjn5j ovos-core if v in sess.valid_languages: ovos-core-86bc9bc566-vjn5j ovos-core ^^^^^^^^^^^^^^^^^^^^ ovos-core-86bc9bc566-vjn5j ovos-core AttributeError: 'Session' object has no attribute 'valid_languages' `` * Update unit_tests.yml * Update test_session.py --- .github/workflows/unit_tests.yml | 4 ++-- ovos_core/intent_services/__init__.py | 4 ++-- test/end2end/session/test_session.py | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index e7cbc6d6e580..0f5cdbffbe49 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -60,7 +60,7 @@ jobs: pip install ./test/end2end/skill-ovos-fallback-unknownv1 pip install ./test/end2end/skill-converse_test pip install ./test/end2end/skill-ovos-schedule - pip install git+https://github.com/OpenVoiceOS/ovos-utils@troubleshoot + pip install git+https://github.com/OpenVoiceOS/ovos-utils - name: Run unittests run: | pytest --cov=ovos_core --cov-report xml test/unittests @@ -92,4 +92,4 @@ jobs: files: ./coverage.xml,!./cache flags: unittests name: codecov-umbrella - verbose: true \ No newline at end of file + verbose: true diff --git a/ovos_core/intent_services/__init__.py b/ovos_core/intent_services/__init__.py index 0386c30dcdb4..205c093ba78a 100644 --- a/ovos_core/intent_services/__init__.py +++ b/ovos_core/intent_services/__init__.py @@ -180,15 +180,15 @@ def disambiguate_lang(message): 3 - detected_lang -> tagged by transformers (text classification, free form chat) 4 - config lang (or from message.data) """ - sess = SessionManager.get(message) default_lang = get_message_lang(message) + valid_langs = [default_lang] + Configuration().get("secondary_langs", []) lang_keys = ["stt_lang", "request_lang", "detected_lang"] for k in lang_keys: if k in message.context: v = message.context[k] - if v in sess.valid_languages: + if v in valid_langs: if v != default_lang: LOG.info(f"replaced {default_lang} with {k}: {v}") return v diff --git a/test/end2end/session/test_session.py b/test/end2end/session/test_session.py index d90b0b42974e..7bca54fc6e0c 100644 --- a/test/end2end/session/test_session.py +++ b/test/end2end/session/test_session.py @@ -206,7 +206,6 @@ def wait_for_n_messages(n): # test deserialization of payload sess = Session.deserialize(messages[10].data["session_data"]) self.assertEqual(sess.session_id, "default") - self.assertEqual(sess.valid_languages, ["en-us"]) # test that active skills list has been updated self.assertEqual(messages[10].data["session_data"]["active_skills"][0][0], self.skill_id)