Skip to content

Commit

Permalink
fix lang detect (#379)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
JarbasAl authored Dec 7, 2023
1 parent b211a98 commit 8e947fc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -92,4 +92,4 @@ jobs:
files: ./coverage.xml,!./cache
flags: unittests
name: codecov-umbrella
verbose: true
verbose: true
4 changes: 2 additions & 2 deletions ovos_core/intent_services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion test/end2end/session/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8e947fc

Please sign in to comment.