From 62623bb2e4da9fa2278ddbae02ff42ec52821ae1 Mon Sep 17 00:00:00 2001 From: JarbasAI <33701864+JarbasAl@users.noreply.github.com> Date: Wed, 16 Oct 2024 04:12:43 +0100 Subject: [PATCH 1/3] fix:standardize_lang (#568) * fix:standardize_lang * fix:standardize_lang * fix:standardize_lang * fix:standardize_lang * fix:standardize_lang * fix:standardize_lang * fix:standardize_lang * fix:standardize_lang * fix:standardize_lang * fix:standardize_lang * fix:standardize_lang * fix:standardize_lang * fix:standardize_lang --- ovos_core/intent_services/__init__.py | 2 + ovos_core/intent_services/converse_service.py | 60 ++++++++++--------- ovos_core/intent_services/fallback_service.py | 28 +++++---- ovos_core/intent_services/stop_service.py | 49 ++++++++------- requirements/lgpl.txt | 2 +- requirements/plugins.txt | 2 +- requirements/requirements.txt | 14 ++--- test/backwards_compat/test_ocp.py | 14 ++--- test/end2end/routing/test_sched.py | 2 +- test/end2end/routing/test_session.py | 2 +- test/end2end/session/test_blacklist.py | 6 +- test/end2end/session/test_complete_failure.py | 8 +-- test/end2end/session/test_converse.py | 10 ++-- test/end2end/session/test_fallback.py | 6 +- test/end2end/session/test_get_response.py | 30 +++++----- test/end2end/session/test_sched.py | 14 ++--- test/end2end/session/test_session.py | 10 ++-- test/end2end/session/test_stop.py | 4 +- test/end2end/session/test_transformers.py | 4 +- .../common_query/test_continuous_dialog.py | 4 +- test/integrationtests/test_workshop.py | 16 ++--- test/unittests/test_intent_service.py | 12 ++-- test/unittests/xformers.py | 2 +- 23 files changed, 161 insertions(+), 140 deletions(-) diff --git a/ovos_core/intent_services/__init__.py b/ovos_core/intent_services/__init__.py index 7e51f9fbd44b..05d46e143d80 100644 --- a/ovos_core/intent_services/__init__.py +++ b/ovos_core/intent_services/__init__.py @@ -29,6 +29,7 @@ from ovos_core.intent_services.stop_service import StopService from ovos_core.transformers import MetadataTransformersService, UtteranceTransformersService from ovos_plugin_manager.templates.pipeline import IntentMatch +from ovos_utils.lang import standardize_lang_tag from ovos_utils.log import LOG, deprecated, log_deprecation from ovos_utils.metrics import Stopwatch from padacioso.opm import PadaciosoPipeline as PadaciosoService @@ -352,6 +353,7 @@ def get_pipeline(self, skips=None, session=None) -> Tuple[str, Callable]: def _validate_session(self, message, lang): # get session + lang = standardize_lang_tag(lang) sess = SessionManager.get(message) if sess.session_id == "default": updated = False diff --git a/ovos_core/intent_services/converse_service.py b/ovos_core/intent_services/converse_service.py index 9e51db0285a4..ace8b73725ab 100644 --- a/ovos_core/intent_services/converse_service.py +++ b/ovos_core/intent_services/converse_service.py @@ -1,16 +1,18 @@ import time from threading import Event -from typing import Optional +from typing import Optional, List from ovos_bus_client.message import Message -from ovos_bus_client.session import SessionManager, UtteranceState +from ovos_bus_client.session import SessionManager, UtteranceState, Session from ovos_bus_client.util import get_message_lang +from ovos_workshop.permissions import ConverseMode, ConverseActivationMode + from ovos_config.config import Configuration from ovos_config.locale import setup_locale from ovos_plugin_manager.templates.pipeline import IntentMatch, PipelinePlugin from ovos_utils import flatten_list +from ovos_utils.lang import standardize_lang_tag from ovos_utils.log import LOG -from ovos_workshop.permissions import ConverseMode, ConverseActivationMode class ConverseService(PipelinePlugin): @@ -26,14 +28,7 @@ def __init__(self, bus): self.bus.on('intent.service.active_skills.get', self.handle_get_active_skills) self.bus.on("skill.converse.get_response.enable", self.handle_get_response_enable) self.bus.on("skill.converse.get_response.disable", self.handle_get_response_disable) - - @property - def config(self): - """ - Returns: - converse_config (dict): config for converse handling options - """ - return Configuration().get("skills", {}).get("converse") or {} + super().__init__(config=Configuration().get("skills", {}).get("converse") or {}) @property def active_skills(self): @@ -47,7 +42,8 @@ def active_skills(self, val): for skill_id, ts in val: session.activate_skill(skill_id) - def get_active_skills(self, message=None): + @staticmethod + def get_active_skills(message: Optional[Message] = None) -> List[str]: """Active skill ids ordered by converse priority this represents the order in which converse will be called @@ -57,12 +53,14 @@ def get_active_skills(self, message=None): session = SessionManager.get(message) return [skill[0] for skill in session.active_skills] - def deactivate_skill(self, skill_id, source_skill=None, message=None): + def deactivate_skill(self, skill_id: str, source_skill: Optional[str] = None, + message: Optional[Message] = None): """Remove a skill from being targetable by converse. Args: skill_id (str): skill to remove source_skill (str): skill requesting the removal + message (Message): the bus message that requested deactivation """ source_skill = source_skill or skill_id if self._deactivate_allowed(skill_id, source_skill): @@ -81,7 +79,8 @@ def deactivate_skill(self, skill_id, source_skill=None, message=None): if skill_id in self._consecutive_activations: self._consecutive_activations[skill_id] = 0 - def activate_skill(self, skill_id, source_skill=None, message=None): + def activate_skill(self, skill_id: str, source_skill: Optional[str] = None, + message: Optional[Message] = None) -> Optional[Session]: """Add a skill or update the position of an active skill. The skill is added to the front of the list, if it's already in the @@ -90,6 +89,7 @@ def activate_skill(self, skill_id, source_skill=None, message=None): Args: skill_id (str): identifier of skill to be added. source_skill (str): skill requesting the removal + message (Message): the bus message that requested activation """ source_skill = source_skill or skill_id if self._activate_allowed(skill_id, source_skill): @@ -108,7 +108,7 @@ def activate_skill(self, skill_id, source_skill=None, message=None): self._consecutive_activations[skill_id] += 1 return session - def _activate_allowed(self, skill_id, source_skill=None): + def _activate_allowed(self, skill_id: str, source_skill: Optional[str] = None) -> bool: """Checks if a skill_id is allowed to jump to the front of active skills list - can a skill activate a different skill @@ -166,7 +166,7 @@ def _activate_allowed(self, skill_id, source_skill=None): return False # skill exceeded authorized consecutive number of activations return True - def _deactivate_allowed(self, skill_id, source_skill=None): + def _deactivate_allowed(self, skill_id: str, source_skill: Optional[str] = None) -> bool: """Checks if a skill_id is allowed to be removed from active skills list - can a skill deactivate a different skill @@ -186,7 +186,7 @@ def _deactivate_allowed(self, skill_id, source_skill=None): return False return True - def _converse_allowed(self, skill_id): + def _converse_allowed(self, skill_id: str) -> bool: """Checks if a skill_id is allowed to converse - is the skill blacklisted from conversing @@ -208,7 +208,7 @@ def _converse_allowed(self, skill_id): return False return True - def _collect_converse_skills(self, message): + def _collect_converse_skills(self, message: Message) -> List[str]: """use the messagebus api to determine which skills want to converse This includes all skills and external applications""" session = SessionManager.get(message) @@ -256,7 +256,7 @@ def handle_ack(msg): self.bus.remove("skill.converse.pong", handle_ack) return want_converse - def _check_converse_timeout(self, message): + def _check_converse_timeout(self, message: Message): """ filter active skill list based on timestamps """ timeouts = self.config.get("skill_timeouts") or {} def_timeout = self.config.get("timeout", 300) @@ -265,7 +265,7 @@ def _check_converse_timeout(self, message): skill for skill in session.active_skills if time.time() - skill[1] <= timeouts.get(skill[0], def_timeout)] - def converse(self, utterances, skill_id, lang, message): + def converse(self, utterances: List[str], skill_id: str, lang: str, message: Message) -> bool: """Call skill and ask if they want to process the utterance. Args: @@ -278,6 +278,7 @@ def converse(self, utterances, skill_id, lang, message): Returns: handled (bool): True if handled otherwise False. """ + lang = standardize_lang_tag(lang) session = SessionManager.get(message) session.lang = lang @@ -312,7 +313,7 @@ def converse(self, utterances, skill_id, lang, message): f'increasing "max_skill_runtime" in mycroft.conf might help alleviate this issue') return False - def converse_with_skills(self, utterances, lang, message) -> Optional[IntentMatch]: + def converse_with_skills(self, utterances: List[str], lang: str, message: Message) -> Optional[IntentMatch]: """Give active skills a chance at the utterance Args: @@ -323,6 +324,7 @@ def converse_with_skills(self, utterances, lang, message) -> Optional[IntentMatc Returns: IntentMatch if handled otherwise None. """ + lang = standardize_lang_tag(lang) session = SessionManager.get(message) # we call flatten in case someone is sending the old style list of tuples @@ -344,21 +346,23 @@ def converse_with_skills(self, utterances, lang, message) -> Optional[IntentMatc utterance=utterances[0]) return None - def handle_get_response_enable(self, message): + @staticmethod + def handle_get_response_enable(message: Message): skill_id = message.data["skill_id"] session = SessionManager.get(message) session.enable_response_mode(skill_id) if session.session_id == "default": SessionManager.sync(message) - def handle_get_response_disable(self, message): + @staticmethod + def handle_get_response_disable(message: Message): skill_id = message.data["skill_id"] session = SessionManager.get(message) session.disable_response_mode(skill_id) if session.session_id == "default": SessionManager.sync(message) - def handle_activate_skill_request(self, message): + def handle_activate_skill_request(self, message: Message): # TODO imperfect solution - only a skill can activate itself # someone can forge this message and emit it raw, but in OpenVoiceOS all # skill messages should have skill_id in context, so let's make sure @@ -370,7 +374,7 @@ def handle_activate_skill_request(self, message): if sess.session_id == "default": SessionManager.sync(message) - def handle_deactivate_skill_request(self, message): + def handle_deactivate_skill_request(self, message: Message): # TODO imperfect solution - only a skill can deactivate itself # someone can forge this message and emit it raw, but in ovos-core all # skill message should have skill_id in context, so let's make sure @@ -382,9 +386,9 @@ def handle_deactivate_skill_request(self, message): if sess.session_id == "default": SessionManager.sync(message) - def reset_converse(self, message): + def reset_converse(self, message: Message): """Let skills know there was a problem with speech recognition""" - lang = get_message_lang(message) + lang = get_message_lang() try: setup_locale(lang) # restore default lang except Exception as e: @@ -392,7 +396,7 @@ def reset_converse(self, message): self.converse_with_skills([], lang, message) - def handle_get_active_skills(self, message): + def handle_get_active_skills(self, message: Message): """Send active skills to caller. Argument: diff --git a/ovos_core/intent_services/fallback_service.py b/ovos_core/intent_services/fallback_service.py index 165a0b6bf45d..ce567ada3410 100644 --- a/ovos_core/intent_services/fallback_service.py +++ b/ovos_core/intent_services/fallback_service.py @@ -16,14 +16,17 @@ import operator import time from collections import namedtuple -from typing import Optional +from typing import Optional, List +from ovos_bus_client.message import Message from ovos_bus_client.session import SessionManager +from ovos_workshop.permissions import FallbackMode + from ovos_config import Configuration from ovos_plugin_manager.templates.pipeline import IntentMatch, PipelinePlugin from ovos_utils import flatten_list +from ovos_utils.lang import standardize_lang_tag from ovos_utils.log import LOG -from ovos_workshop.permissions import FallbackMode FallbackRange = namedtuple('FallbackRange', ['start', 'stop']) @@ -39,7 +42,7 @@ def __init__(self, bus): self.bus.on("ovos.skills.fallback.deregister", self.handle_deregister_fallback) super().__init__(self.fallback_config) - def handle_register_fallback(self, message): + def handle_register_fallback(self, message: Message): skill_id = message.data.get("skill_id") priority = message.data.get("priority") or 101 @@ -52,12 +55,12 @@ def handle_register_fallback(self, message): else: self.registered_fallbacks[skill_id] = priority - def handle_deregister_fallback(self, message): + def handle_deregister_fallback(self, message: Message): skill_id = message.data.get("skill_id") if skill_id in self.registered_fallbacks: self.registered_fallbacks.pop(skill_id) - def _fallback_allowed(self, skill_id): + def _fallback_allowed(self, skill_id: str) -> bool: """Checks if a skill_id is allowed to fallback - is the skill blacklisted from fallback @@ -78,7 +81,8 @@ def _fallback_allowed(self, skill_id): return False return True - def _collect_fallback_skills(self, message, fb_range=FallbackRange(0, 100)): + def _collect_fallback_skills(self, message: Message, + fb_range: FallbackRange = FallbackRange(0, 100)) -> List[str]: """use the messagebus api to determine which skills have registered fallback handlers This includes all skills and external applications""" skill_ids = [] # skill_ids that already answered to ping @@ -116,7 +120,7 @@ def handle_ack(msg): self.bus.remove("ovos.skills.fallback.pong", handle_ack) return fallback_skills - def attempt_fallback(self, utterances, skill_id, lang, message): + def attempt_fallback(self, utterances: List[str], skill_id: str, lang: str, message: Message) -> bool: """Call skill and ask if they want to process the utterance. Args: @@ -158,7 +162,8 @@ def attempt_fallback(self, utterances, skill_id, lang, message): f'increasing "max_skill_runtime" in mycroft.conf might help alleviate this issue') return False - def _fallback_range(self, utterances, lang, message, fb_range) -> Optional[IntentMatch]: + def _fallback_range(self, utterances: List[str], lang: str, + message: Message, fb_range: FallbackRange) -> Optional[IntentMatch]: """Send fallback request for a specified priority range. Args: @@ -171,6 +176,7 @@ def _fallback_range(self, utterances, lang, message, fb_range) -> Optional[Inten Returns: IntentMatch or None """ + lang = standardize_lang_tag(lang) # we call flatten in case someone is sending the old style list of tuples utterances = flatten_list(utterances) message.data["utterances"] = utterances # all transcripts @@ -195,17 +201,17 @@ def _fallback_range(self, utterances, lang, message, fb_range) -> Optional[Inten utterance=utterances[0]) return None - def high_prio(self, utterances, lang, message) -> Optional[IntentMatch]: + def high_prio(self, utterances: List[str], lang: str, message: Message) -> Optional[IntentMatch]: """Pre-padatious fallbacks.""" return self._fallback_range(utterances, lang, message, FallbackRange(0, 5)) - def medium_prio(self, utterances, lang, message) -> Optional[IntentMatch]: + def medium_prio(self, utterances: List[str], lang: str, message: Message) -> Optional[IntentMatch]: """General fallbacks.""" return self._fallback_range(utterances, lang, message, FallbackRange(5, 90)) - def low_prio(self, utterances, lang, message) -> Optional[IntentMatch]: + def low_prio(self, utterances: List[str], lang: str, message: Message) -> Optional[IntentMatch]: """Low prio fallbacks with general matching such as chat-bot.""" return self._fallback_range(utterances, lang, message, FallbackRange(90, 101)) diff --git a/ovos_core/intent_services/stop_service.py b/ovos_core/intent_services/stop_service.py index 86a45e3f47cf..bdb1137a75f2 100644 --- a/ovos_core/intent_services/stop_service.py +++ b/ovos_core/intent_services/stop_service.py @@ -4,12 +4,15 @@ from threading import Event from typing import Optional, List +from langcodes import closest_match from ovos_bus_client.message import Message from ovos_bus_client.session import SessionManager + from ovos_config.config import Configuration from ovos_plugin_manager.templates.pipeline import IntentMatch, PipelinePlugin from ovos_utils import flatten_list from ovos_utils.bracket_expansion import expand_options +from ovos_utils.lang import standardize_lang_tag from ovos_utils.log import LOG from ovos_utils.parse import match_one @@ -21,11 +24,12 @@ def __init__(self, bus): self.bus = bus self._voc_cache = {} self.load_resource_files() + super().__init__(config=Configuration().get("skills", {}).get("stop") or {}) def load_resource_files(self): base = f"{dirname(__file__)}/locale" for lang in os.listdir(base): - lang2 = lang.split("-")[0].lower() + lang2 = standardize_lang_tag(lang) self._voc_cache[lang2] = {} for f in os.listdir(f"{base}/{lang}"): with open(f"{base}/{lang}/{f}", encoding="utf-8") as fi: @@ -34,15 +38,8 @@ def load_resource_files(self): n = f.split(".", 1)[0] self._voc_cache[lang2][n] = flatten_list(lines) - @property - def config(self): - """ - Returns: - stop_config (dict): config for stop handling options - """ - return Configuration().get("skills", {}).get("stop") or {} - - def get_active_skills(self, message: Optional[Message] = None): + @staticmethod + def get_active_skills(message: Optional[Message] = None) -> List[str]: """Active skill ids ordered by converse priority this represents the order in which stop will be called @@ -52,7 +49,7 @@ def get_active_skills(self, message: Optional[Message] = None): session = SessionManager.get(message) return [skill[0] for skill in session.active_skills] - def _collect_stop_skills(self, message: Message): + def _collect_stop_skills(self, message: Message) -> List[str]: """use the messagebus api to determine which skills can stop This includes all skills and external applications""" @@ -96,7 +93,7 @@ def handle_ack(msg): self.bus.remove("skill.stop.pong", handle_ack) return want_stop or active_skills - def stop_skill(self, skill_id: str, message: Message): + def stop_skill(self, skill_id: str, message: Message) -> bool: """Tell a skill to stop anything it's doing, taking into account the message Session @@ -127,8 +124,8 @@ def match_stop_high(self, utterances: List[str], lang: str, message: Message) -> Returns: IntentMatch if handled otherwise None. """ - lang = lang.split("-")[0] - if lang not in self._voc_cache: + lang = self._get_closest_lang(lang) + if lang is None: # no vocs registered for this lang return None sess = SessionManager.get(message) @@ -178,8 +175,8 @@ def match_stop_medium(self, utterances: List[str], lang: str, message: Message) Returns: IntentMatch if handled otherwise None. """ - lang = lang.split("-")[0] - if lang not in self._voc_cache: + lang = self._get_closest_lang(lang) + if lang is None: # no vocs registered for this lang return None # we call flatten in case someone is sending the old style list of tuples @@ -194,6 +191,18 @@ def match_stop_medium(self, utterances: List[str], lang: str, message: Message) return self.match_stop_low(utterances, lang, message) + def _get_closest_lang(self, lang: str) -> Optional[str]: + if self._voc_cache: + lang = standardize_lang_tag(lang) + closest, score = closest_match(lang, list(self._voc_cache.keys())) + # https://langcodes-hickford.readthedocs.io/en/sphinx/index.html#distance-values + # 0 -> These codes represent the same language, possibly after filling in values and normalizing. + # 1- 3 -> These codes indicate a minor regional difference. + # 4 - 10 -> These codes indicate a significant but unproblematic regional difference. + if score < 10: + return closest + return None + def match_stop_low(self, utterances: List[str], lang: str, message: Message) -> Optional[IntentMatch]: """ before fallback_low , fuzzy match stop intent @@ -205,8 +214,8 @@ def match_stop_low(self, utterances: List[str], lang: str, message: Message) -> Returns: IntentMatch if handled otherwise None. """ - lang = lang.split("-")[0] - if lang not in self._voc_cache: + lang = self._get_closest_lang(lang) + if lang is None: # no vocs registered for this lang return None sess = SessionManager.get(message) # we call flatten in case someone is sending the old style list of tuples @@ -266,8 +275,8 @@ def voc_match(self, utt: str, voc_filename: str, lang: str, Returns: bool: True if the utterance has the given vocabulary it """ - lang = lang.split("-")[0].lower() - if lang not in self._voc_cache: + lang = self._get_closest_lang(lang) + if lang is None: # no vocs registered for this lang return False _vocs = self._voc_cache[lang].get(voc_filename) or [] diff --git a/requirements/lgpl.txt b/requirements/lgpl.txt index 74a4b7a01a4f..e92ee3c4a82f 100644 --- a/requirements/lgpl.txt +++ b/requirements/lgpl.txt @@ -1,2 +1,2 @@ -ovos_padatious>=0.1.2,<1.0.0 +ovos_padatious>=0.1.3,<1.0.0 fann2>=1.0.7, < 1.1.0 diff --git a/requirements/plugins.txt b/requirements/plugins.txt index e4305a653301..c5e9c288726a 100644 --- a/requirements/plugins.txt +++ b/requirements/plugins.txt @@ -1,5 +1,5 @@ ovos-utterance-corrections-plugin>=0.0.2, <1.0.0 -ovos-utterance-plugin-cancel>=0.2.0, <1.0.0 +ovos-utterance-plugin-cancel>=0.2.2, <1.0.0 ovos-bidirectional-translation-plugin>=0.1.0, <1.0.0 ovos-translate-server-plugin>=0.0.2, <1.0.0 ovos-utterance-normalizer>=0.2.1, <1.0.0 diff --git a/requirements/requirements.txt b/requirements/requirements.txt index cc8bf73a38ed..14d54b1f6307 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -3,15 +3,15 @@ python-dateutil>=2.6, <3.0 watchdog>=2.1, <3.0 combo-lock>=0.2.2, <0.3 -padacioso>=0.2.2,<1.0.0 -ovos-adapt-parser>=0.1.2, <1.0.0 -ovos_ocp_pipeline_plugin>=0.1.2, <1.0.0 -ovos-common-query-pipeline-plugin>=0.1.2, <1.0.0 +padacioso>=0.2.4,<1.0.0 +ovos-adapt-parser>=0.1.3, <1.0.0 +ovos_ocp_pipeline_plugin>=0.1.3, <1.0.0 +ovos-common-query-pipeline-plugin>=0.1.4, <1.0.0 -ovos-utils>=0.1.0,<1.0.0 -ovos_bus_client>=0.1.0,<1.0.0 +ovos-utils>=0.3.5,<1.0.0 +ovos_bus_client>=0.1.4,<1.0.0 ovos-plugin-manager>=0.0.26,<1.0.0 ovos-config>=0.0.13,<1.0.0 ovos-lingua-franca>=0.4.7,<1.0.0 ovos-backend-client>=0.1.0,<2.0.0 -ovos-workshop>=0.0.16,<2.0.0 \ No newline at end of file +ovos-workshop>=1.0.1,<2.0.0 \ No newline at end of file diff --git a/test/backwards_compat/test_ocp.py b/test/backwards_compat/test_ocp.py index 0a3f704ccf75..faf389a9c124 100644 --- a/test/backwards_compat/test_ocp.py +++ b/test/backwards_compat/test_ocp.py @@ -201,31 +201,31 @@ def test_auto_unload(self): {'type': 'padatious:register_intent', 'data': { 'file_name': f'{locale_folder}/play.intent', - 'name': 'ovos.common_play:play.intent', 'lang': 'en-us'}}, + 'name': 'ovos.common_play:play.intent', 'lang': 'en-US'}}, {'type': 'padatious:register_intent', 'data': { 'file_name': f'{locale_folder}/read.intent', - 'name': 'ovos.common_play:read.intent', 'lang': 'en-us'}}, + 'name': 'ovos.common_play:read.intent', 'lang': 'en-US'}}, {'type': 'padatious:register_intent', 'data': { 'file_name': f'{locale_folder}/open.intent', - 'name': 'ovos.common_play:open.intent', 'lang': 'en-us'}}, + 'name': 'ovos.common_play:open.intent', 'lang': 'en-US'}}, {'type': 'padatious:register_intent', 'data': { 'file_name': f'{locale_folder}/next.intent', - 'name': 'ovos.common_play:next.intent', 'lang': 'en-us'}}, + 'name': 'ovos.common_play:next.intent', 'lang': 'en-US'}}, {'type': 'padatious:register_intent', 'data': { 'file_name': f'{locale_folder}/prev.intent', - 'name': 'ovos.common_play:prev.intent', 'lang': 'en-us'}}, + 'name': 'ovos.common_play:prev.intent', 'lang': 'en-US'}}, {'type': 'padatious:register_intent', 'data': { 'file_name': f'{locale_folder}/pause.intent', - 'name': 'ovos.common_play:pause.intent', 'lang': 'en-us'}}, + 'name': 'ovos.common_play:pause.intent', 'lang': 'en-US'}}, {'type': 'padatious:register_intent', 'data': { 'file_name': f'{locale_folder}/resume.intent', - 'name': 'ovos.common_play:resume.intent', 'lang': 'en-us'}}, + 'name': 'ovos.common_play:resume.intent', 'lang': 'en-US'}}, {'type': 'ovos.common_play.skills.get', 'data': {}} ] diff --git a/test/end2end/routing/test_sched.py b/test/end2end/routing/test_sched.py index 66a6350fdceb..f9bf8000e135 100644 --- a/test/end2end/routing/test_sched.py +++ b/test/end2end/routing/test_sched.py @@ -16,7 +16,7 @@ def setUp(self): def test_no_session(self): SessionManager.sessions = {} SessionManager.default_session = SessionManager.sessions["default"] = Session("default") - SessionManager.default_session.lang = "en-us" + SessionManager.default_session.lang = "en-US" SessionManager.pipeline = ["adapt_high"] messages = [] diff --git a/test/end2end/routing/test_session.py b/test/end2end/routing/test_session.py index d1777e13e160..5adce21102a6 100644 --- a/test/end2end/routing/test_session.py +++ b/test/end2end/routing/test_session.py @@ -21,7 +21,7 @@ def tearDown(self) -> None: def test_no_session(self): SessionManager.sessions = {} SessionManager.default_session = SessionManager.sessions["default"] = Session("default") - SessionManager.default_session.lang = "en-us" + SessionManager.default_session.lang = "en-US" SessionManager.pipeline = ["adapt_high"] messages = [] diff --git a/test/end2end/session/test_blacklist.py b/test/end2end/session/test_blacklist.py index 340bef1869d0..11a3df6428e3 100644 --- a/test/end2end/session/test_blacklist.py +++ b/test/end2end/session/test_blacklist.py @@ -21,7 +21,7 @@ def tearDown(self) -> None: def test_blacklist(self): SessionManager.sessions = {} SessionManager.default_session = SessionManager.sessions["default"] = Session("default") - SessionManager.default_session.lang = "en-us" + SessionManager.default_session.lang = "en-US" SessionManager.default_session.pipeline = ["adapt_high"] SessionManager.default_session.blacklisted_skills = [] SessionManager.default_session.blacklisted_intents = [] @@ -309,7 +309,7 @@ def tearDown(self) -> None: def test_fallback(self): SessionManager.sessions = {} SessionManager.default_session = SessionManager.sessions["default"] = Session("default") - SessionManager.default_session.lang = "en-us" + SessionManager.default_session.lang = "en-US" SessionManager.default_session.pipeline = [ "fallback_high" ] @@ -400,7 +400,7 @@ def tearDown(self) -> None: def test_common_qa(self): SessionManager.sessions = {} SessionManager.default_session = SessionManager.sessions["default"] = Session("default") - SessionManager.default_session.lang = "en-us" + SessionManager.default_session.lang = "en-US" SessionManager.default_session.pipeline = ["common_qa"] messages = [] diff --git a/test/end2end/session/test_complete_failure.py b/test/end2end/session/test_complete_failure.py index b72c3ff8008a..10da8f11d444 100644 --- a/test/end2end/session/test_complete_failure.py +++ b/test/end2end/session/test_complete_failure.py @@ -19,7 +19,7 @@ def tearDown(self) -> None: def test_complete_failure(self): SessionManager.sessions = {} SessionManager.default_session = SessionManager.sessions["default"] = Session("default") - SessionManager.default_session.lang = "en-us" + SessionManager.default_session.lang = "en-US" SessionManager.default_session.active_skills = [(self.skill_id, time.time())] SessionManager.default_session.pipeline = [ "stop_high", @@ -105,7 +105,7 @@ def wait_for_n_messages(n): def test_complete_failure_lang_detect(self): SessionManager.sessions = {} SessionManager.default_session = SessionManager.sessions["default"] = Session("default") - SessionManager.default_session.lang = "en-us" + SessionManager.default_session.lang = "en-US" SessionManager.default_session.active_skills = [(self.skill_id, time.time())] SessionManager.default_session.pipeline = [ "stop_high", @@ -144,7 +144,7 @@ def wait_for_n_messages(n): self.core.bus.on("message", new_msg) - SessionManager.default_session.valid_languages = ["en-us", stt_lang_detect, "fr-fr"] + SessionManager.default_session.valid_languages = ["en-US", stt_lang_detect, "fr-fr"] utt = Message("recognizer_loop:utterance", {"utterances": ["hello world"]}, {"session": SessionManager.default_session.serialize(), @@ -247,4 +247,4 @@ def wait_for_n_messages(n): self.assertEqual(messages[18].data["session_data"]["lang"], "pt-pt") self.assertEqual(SessionManager.default_session.lang, "pt-pt") - SessionManager.default_session.lang = "en-us" + SessionManager.default_session.lang = "en-US" diff --git a/test/end2end/session/test_converse.py b/test/end2end/session/test_converse.py index 4dc622c59a0e..e7f0e2d31856 100644 --- a/test/end2end/session/test_converse.py +++ b/test/end2end/session/test_converse.py @@ -21,7 +21,7 @@ def tearDown(self) -> None: def test_no_session(self): SessionManager.sessions = {} SessionManager.default_session = SessionManager.sessions["default"] = Session("default") - SessionManager.default_session.lang = "en-us" + SessionManager.default_session.lang = "en-US" SessionManager.default_session.pipeline = [ "converse", "padatious_high", @@ -85,7 +85,7 @@ def wait_for_n_messages(n): # (missing in utterance message) and kept in all messages for m in messages[1:]: self.assertEqual(m.context["session"]["session_id"], "default") - self.assertEqual(m.context["lang"], "en-us") + self.assertEqual(m.context["lang"], "en-US") # verify skill is activated self.assertEqual(messages[1].msg_type, "intent.service.skills.activated") @@ -157,7 +157,7 @@ def wait_for_n_messages(n): # (missing in utterance message) and kept in all messages for m in messages[1:]: self.assertEqual(m.context["session"]["session_id"], "default") - self.assertEqual(m.context["lang"], "en-us") + self.assertEqual(m.context["lang"], "en-US") # verify that "lang" is injected by converse.ping # (missing in utterance message) and kept in all messages @@ -250,7 +250,7 @@ def wait_for_n_messages(n): # (missing in utterance message) and kept in all messages for m in messages[1:]: self.assertEqual(m.context["session"]["session_id"], "default") - self.assertEqual(m.context["lang"], "en-us") + self.assertEqual(m.context["lang"], "en-US") # converse self.assertEqual(messages[1].msg_type, f"{self.other_skill_id}.converse.ping") @@ -339,7 +339,7 @@ def wait_for_n_messages(n): # (missing in utterance message) and kept in all messages for m in messages[1:]: self.assertEqual(m.context["session"]["session_id"], "default") - self.assertEqual(m.context["lang"], "en-us") + self.assertEqual(m.context["lang"], "en-US") # converse self.assertEqual(messages[1].msg_type, f"{self.skill_id}.converse.ping") diff --git a/test/end2end/session/test_fallback.py b/test/end2end/session/test_fallback.py index edb0030240a6..facdaba0667d 100644 --- a/test/end2end/session/test_fallback.py +++ b/test/end2end/session/test_fallback.py @@ -19,7 +19,7 @@ def tearDown(self) -> None: def test_fallback(self): SessionManager.sessions = {} SessionManager.default_session = SessionManager.sessions["default"] = Session("default") - SessionManager.default_session.lang = "en-us" + SessionManager.default_session.lang = "en-US" SessionManager.default_session.pipeline = [ "converse", "fallback_high", @@ -142,7 +142,7 @@ def wait_for_n_messages(n): def test_fallback_with_session(self): SessionManager.sessions = {} SessionManager.default_session = SessionManager.sessions["default"] = Session("default") - SessionManager.default_session.lang = "en-us" + SessionManager.default_session.lang = "en-US" SessionManager.default_session.pipeline = [ "fallback_high", "fallback_medium", @@ -316,7 +316,7 @@ def tearDown(self) -> None: def test_fallback(self): SessionManager.sessions = {} SessionManager.default_session = SessionManager.sessions["default"] = Session("default") - SessionManager.default_session.lang = "en-us" + SessionManager.default_session.lang = "en-US" SessionManager.default_session.pipeline = [ "fallback_medium", "fallback_low" diff --git a/test/end2end/session/test_get_response.py b/test/end2end/session/test_get_response.py index 73f80a1e69e0..42fd20cf76c3 100644 --- a/test/end2end/session/test_get_response.py +++ b/test/end2end/session/test_get_response.py @@ -20,7 +20,7 @@ def tearDown(self) -> None: def test_no_response(self): SessionManager.sessions = {} SessionManager.default_session = SessionManager.sessions["default"] = Session("default") - SessionManager.default_session.lang = "en-us" + SessionManager.default_session.lang = "en-US" SessionManager.default_session.pipeline = [ "converse", "padatious_high", @@ -100,7 +100,7 @@ def on_speak(msg): # (missing in utterance message) and kept in all messages for m in messages[1:]: self.assertEqual(m.context["session"]["session_id"], "default") - self.assertEqual(m.context["lang"], "en-us") + self.assertEqual(m.context["lang"], "en-US") # verify intent triggers self.assertEqual(messages[3].msg_type, f"{self.skill_id}:test_get_response.intent") @@ -125,7 +125,7 @@ def on_speak(msg): self.assertEqual(messages[7].msg_type, "enclosure.active_skill") self.assertEqual(messages[7].data["skill_id"], self.skill_id) self.assertEqual(messages[8].msg_type, "speak") - self.assertEqual(messages[8].data["lang"], "en-us") + self.assertEqual(messages[8].data["lang"], "en-US") self.assertTrue(messages[8].data["expect_response"]) # listen after dialog self.assertEqual(messages[8].data["meta"]["skill"], self.skill_id) self.assertEqual(messages[9].msg_type, "recognizer_loop:audio_output_start") @@ -142,7 +142,7 @@ def on_speak(msg): self.assertEqual(messages[14].msg_type, "enclosure.active_skill") self.assertEqual(messages[14].data["skill_id"], self.skill_id) self.assertEqual(messages[15].msg_type, "speak") - self.assertEqual(messages[15].data["lang"], "en-us") + self.assertEqual(messages[15].data["lang"], "en-US") self.assertFalse(messages[15].data["expect_response"]) self.assertEqual(messages[15].data["utterance"], "ERROR") self.assertEqual(messages[15].data["meta"]["skill"], self.skill_id) @@ -163,7 +163,7 @@ def on_speak(msg): def test_with_response(self): SessionManager.sessions = {} SessionManager.default_session = SessionManager.sessions["default"] = Session("default") - SessionManager.default_session.lang = "en-us" + SessionManager.default_session.lang = "en-US" SessionManager.default_session.pipeline = [ "converse", "padatious_high", @@ -279,7 +279,7 @@ def answer_get_response(msg): self.assertEqual(messages[7].data["skill_id"], self.skill_id) self.assertEqual(messages[8].msg_type, "speak") self.assertEqual(messages[8].data["utterance"], "give me an answer", ) - self.assertEqual(messages[8].data["lang"], "en-us") + self.assertEqual(messages[8].data["lang"], "en-US") self.assertTrue(messages[8].data["expect_response"]) # listen after dialog self.assertEqual(messages[8].data["meta"]["skill"], self.skill_id) # ovos-audio speak execution (simulated) @@ -308,7 +308,7 @@ def answer_get_response(msg): self.assertEqual(messages[19].msg_type, "enclosure.active_skill") self.assertEqual(messages[19].data["skill_id"], self.skill_id) self.assertEqual(messages[20].msg_type, "speak") - self.assertEqual(messages[20].data["lang"], "en-us") + self.assertEqual(messages[20].data["lang"], "en-US") self.assertFalse(messages[20].data["expect_response"]) self.assertEqual(messages[20].data["utterance"], "ok") self.assertEqual(messages[20].data["meta"]["skill"], self.skill_id) @@ -329,7 +329,7 @@ def answer_get_response(msg): def test_cancel_response(self): SessionManager.sessions = {} SessionManager.default_session = SessionManager.sessions["default"] = Session("default") - SessionManager.default_session.lang = "en-us" + SessionManager.default_session.lang = "en-US" SessionManager.default_session.pipeline = [ "converse", "padatious_high", @@ -445,7 +445,7 @@ def answer_get_response(msg): self.assertEqual(messages[7].data["skill_id"], self.skill_id) self.assertEqual(messages[8].msg_type, "speak") self.assertEqual(messages[8].data["utterance"], "give me an answer", ) - self.assertEqual(messages[8].data["lang"], "en-us") + self.assertEqual(messages[8].data["lang"], "en-US") self.assertTrue(messages[8].data["expect_response"]) # listen after dialog self.assertEqual(messages[8].data["meta"]["skill"], self.skill_id) # ovos-audio speak execution (simulated) @@ -473,7 +473,7 @@ def answer_get_response(msg): self.assertEqual(messages[19].msg_type, "enclosure.active_skill") self.assertEqual(messages[19].data["skill_id"], self.skill_id) self.assertEqual(messages[20].msg_type, "speak") - self.assertEqual(messages[20].data["lang"], "en-us") + self.assertEqual(messages[20].data["lang"], "en-US") self.assertFalse(messages[20].data["expect_response"]) self.assertEqual(messages[20].data["utterance"], "ERROR") self.assertEqual(messages[20].data["meta"]["skill"], self.skill_id) @@ -494,7 +494,7 @@ def answer_get_response(msg): def test_with_reprompt(self): SessionManager.sessions = {} SessionManager.default_session = SessionManager.sessions["default"] = Session("default") - SessionManager.default_session.lang = "en-us" + SessionManager.default_session.lang = "en-US" SessionManager.default_session.pipeline = [ "converse", "padatious_high", @@ -629,7 +629,7 @@ def answer_get_response(msg): self.assertEqual(messages[18].msg_type, "enclosure.active_skill") self.assertEqual(messages[18].data["skill_id"], self.skill_id) self.assertEqual(messages[19].msg_type, "speak") - self.assertEqual(messages[19].data["lang"], "en-us") + self.assertEqual(messages[19].data["lang"], "en-US") self.assertFalse(messages[19].data["expect_response"]) self.assertEqual(messages[19].data["utterance"], "ok") self.assertEqual(messages[19].data["meta"]["skill"], self.skill_id) @@ -647,7 +647,7 @@ def answer_get_response(msg): def test_nested(self): SessionManager.sessions = {} SessionManager.default_session = SessionManager.sessions["default"] = Session("default") - SessionManager.default_session.lang = "en-us" + SessionManager.default_session.lang = "en-US" SessionManager.default_session.pipeline = [ "converse", "padatious_high", @@ -801,7 +801,7 @@ def answer_get_response(msg): self.assertEqual(messages[5].msg_type, "enclosure.active_skill") self.assertEqual(messages[5].data["skill_id"], self.skill_id) self.assertEqual(messages[6].msg_type, "speak") - self.assertEqual(messages[6].data["lang"], "en-us") + self.assertEqual(messages[6].data["lang"], "en-US") self.assertFalse(messages[6].data["expect_response"]) self.assertEqual(messages[6].data["utterance"], "give me items") self.assertEqual(messages[6].data["meta"]["skill"], self.skill_id) @@ -847,7 +847,7 @@ def answer_get_response(msg): def test_kill_response(self): SessionManager.sessions = {} SessionManager.default_session = SessionManager.sessions["default"] = Session("default") - SessionManager.default_session.lang = "en-us" + SessionManager.default_session.lang = "en-US" SessionManager.default_session.pipeline = [ "converse", "padatious_high", diff --git a/test/end2end/session/test_sched.py b/test/end2end/session/test_sched.py index ba08b77df4d7..ef10a7b66400 100644 --- a/test/end2end/session/test_sched.py +++ b/test/end2end/session/test_sched.py @@ -16,7 +16,7 @@ def setUp(self): def test_no_session(self): SessionManager.sessions = {} SessionManager.default_session = SessionManager.sessions["default"] = Session("default") - SessionManager.default_session.lang = "en-us" + SessionManager.default_session.lang = "en-US" SessionManager.default_session.pipeline = [ "adapt_high" ] @@ -74,7 +74,7 @@ def wait_for_n_messages(n): # (missing in utterance message) and kept in all messages for m in messages[1:]: self.assertEqual(m.context["session"]["session_id"], "default") - self.assertEqual(m.context["lang"], "en-us") + self.assertEqual(m.context["lang"], "en-US") # verify skill_id is now present in every message.context self.assertEqual(messages[1].msg_type, "intent.service.skills.activated") @@ -94,7 +94,7 @@ def wait_for_n_messages(n): self.assertEqual(messages[5].msg_type, "enclosure.active_skill") self.assertEqual(messages[5].data["skill_id"], self.skill_id) self.assertEqual(messages[6].msg_type, "speak") - self.assertEqual(messages[6].data["lang"], "en-us") + self.assertEqual(messages[6].data["lang"], "en-US") self.assertFalse(messages[6].data["expect_response"]) self.assertEqual(messages[6].data["meta"]["dialog"], "done") self.assertEqual(messages[6].data["meta"]["skill"], self.skill_id) @@ -122,7 +122,7 @@ def wait_for_n_messages(n): self.assertEqual(messages[12].msg_type, "enclosure.active_skill") self.assertEqual(messages[12].context, intent_context) self.assertEqual(messages[13].msg_type, "speak") - self.assertEqual(messages[13].data["lang"], "en-us") + self.assertEqual(messages[13].data["lang"], "en-US") self.assertFalse(messages[13].data["expect_response"]) self.assertEqual(messages[13].data["meta"]["dialog"], "trigger") self.assertEqual(messages[13].data["meta"]["skill"], self.skill_id) @@ -131,7 +131,7 @@ def wait_for_n_messages(n): def test_explicit_session(self): SessionManager.sessions = {} SessionManager.default_session = SessionManager.sessions["default"] = Session("default") - SessionManager.default_session.lang = "en-us" + SessionManager.default_session.lang = "en-US" SessionManager.default_session.pipeline = [ "adapt_high" ] @@ -212,7 +212,7 @@ def wait_for_n_messages(n): self.assertEqual(messages[5].msg_type, "enclosure.active_skill") self.assertEqual(messages[5].data["skill_id"], self.skill_id) self.assertEqual(messages[6].msg_type, "speak") - self.assertEqual(messages[6].data["lang"], "en-us") + self.assertEqual(messages[6].data["lang"], "en-US") self.assertFalse(messages[6].data["expect_response"]) self.assertEqual(messages[6].data["meta"]["dialog"], "done") self.assertEqual(messages[6].data["meta"]["skill"], self.skill_id) @@ -229,7 +229,7 @@ def wait_for_n_messages(n): self.assertEqual(messages[11].msg_type, "enclosure.active_skill") self.assertEqual(messages[11].context, intent_context) self.assertEqual(messages[12].msg_type, "speak") - self.assertEqual(messages[12].data["lang"], "en-us") + self.assertEqual(messages[12].data["lang"], "en-US") self.assertFalse(messages[12].data["expect_response"]) self.assertEqual(messages[12].data["meta"]["dialog"], "trigger") self.assertEqual(messages[12].data["meta"]["skill"], self.skill_id) diff --git a/test/end2end/session/test_session.py b/test/end2end/session/test_session.py index 14890d5606e3..6fcc200ce4db 100644 --- a/test/end2end/session/test_session.py +++ b/test/end2end/session/test_session.py @@ -20,7 +20,7 @@ def tearDown(self) -> None: def test_no_session(self): SessionManager.sessions = {} SessionManager.default_session = SessionManager.sessions["default"] = Session("default") - SessionManager.default_session.lang = "en-us" + SessionManager.default_session.lang = "en-US" SessionManager.default_session.pipeline = [ "adapt_high" ] @@ -73,7 +73,7 @@ def wait_for_n_messages(n): # (missing in utterance message) and kept in all messages for m in messages[1:]: self.assertEqual(m.context["session"]["session_id"], "default") - self.assertEqual(m.context["lang"], "en-us") + self.assertEqual(m.context["lang"], "en-US") # verify skill is activated self.assertEqual(messages[1].msg_type, "intent.service.skills.activated") @@ -105,7 +105,7 @@ def wait_for_n_messages(n): def test_explicit_default_session(self): SessionManager.sessions = {} SessionManager.default_session = SessionManager.sessions["default"] = Session("default") - SessionManager.default_session.lang = "en-us" + SessionManager.default_session.lang = "en-US" now = time.time() SessionManager.default_session.active_skills = [(self.skill_id, now)] SessionManager.default_session.pipeline = [ @@ -206,7 +206,7 @@ def wait_for_n_messages(n): def test_explicit_session(self): SessionManager.sessions = {} SessionManager.default_session = SessionManager.sessions["default"] = Session("default") - SessionManager.default_session.lang = "en-us" + SessionManager.default_session.lang = "en-US" SessionManager.default_session.pipeline = [ "converse", "adapt_high" @@ -295,7 +295,7 @@ def wait_for_n_messages(n): self.assertEqual(messages[7].msg_type, "enclosure.active_skill") self.assertEqual(messages[7].data["skill_id"], self.skill_id) self.assertEqual(messages[8].msg_type, "speak") - self.assertEqual(messages[8].data["lang"], "en-us") + self.assertEqual(messages[8].data["lang"], "en-US") self.assertFalse(messages[8].data["expect_response"]) self.assertEqual(messages[8].data["meta"]["dialog"], "hello.world") self.assertEqual(messages[8].data["meta"]["skill"], self.skill_id) diff --git a/test/end2end/session/test_stop.py b/test/end2end/session/test_stop.py index ac94f3901e4d..c7c6c6c153a9 100644 --- a/test/end2end/session/test_stop.py +++ b/test/end2end/session/test_stop.py @@ -20,7 +20,7 @@ def tearDown(self) -> None: def test_old_stop(self): SessionManager.sessions = {} SessionManager.default_session = SessionManager.sessions["default"] = Session("default") - SessionManager.default_session.lang = "en-us" + SessionManager.default_session.lang = "en-US" SessionManager.default_session.pipeline = [ "stop_high", "adapt_high" @@ -196,7 +196,7 @@ def wait_for_n_messages(n): def test_new_stop(self): SessionManager.sessions = {} SessionManager.default_session = SessionManager.sessions["default"] = Session("default") - SessionManager.default_session.lang = "en-us" + SessionManager.default_session.lang = "en-US" SessionManager.default_session.pipeline = [ "stop_high", "adapt_high", diff --git a/test/end2end/session/test_transformers.py b/test/end2end/session/test_transformers.py index 127816940a06..525840279432 100644 --- a/test/end2end/session/test_transformers.py +++ b/test/end2end/session/test_transformers.py @@ -32,7 +32,7 @@ def test_cancel(self): SessionManager.sessions = {} SessionManager.default_session = SessionManager.sessions["default"] = Session("default") - SessionManager.default_session.lang = "en-us" + SessionManager.default_session.lang = "en-US" SessionManager.default_session.active_skills = [(self.skill_id, time.time())] SessionManager.default_session.pipeline = [ "stop_high", @@ -105,7 +105,7 @@ def test_meta(self): SessionManager.sessions = {} SessionManager.default_session = SessionManager.sessions["default"] = Session("default") - SessionManager.default_session.lang = "en-us" + SessionManager.default_session.lang = "en-US" SessionManager.default_session.active_skills = [(self.skill_id, time.time())] SessionManager.default_session.pipeline = [ "stop_high", diff --git a/test/integrationtests/common_query/test_continuous_dialog.py b/test/integrationtests/common_query/test_continuous_dialog.py index 9b77c05e963d..96862b486a6a 100644 --- a/test/integrationtests/common_query/test_continuous_dialog.py +++ b/test/integrationtests/common_query/test_continuous_dialog.py @@ -49,7 +49,7 @@ def test_continuous_dialog(self): self.assertEqual(self.bus.emitted_msgs[-1], {'context': {'skill_id': 'wiki.test'}, 'data': {'expect_response': False, - 'lang': 'en-us', + 'lang': 'en-US', 'meta': {'skill': 'wiki.test'}, 'utterance': 'answer 1'}, 'type': 'speak'}) @@ -61,7 +61,7 @@ def test_continuous_dialog(self): self.assertEqual(self.bus.emitted_msgs[-1], {'context': {'skill_id': 'wiki.test'}, 'data': {'expect_response': False, - 'lang': 'en-us', + 'lang': 'en-US', 'meta': {'skill': 'wiki.test'}, 'utterance': 'answer 2'}, 'type': 'speak'}) diff --git a/test/integrationtests/test_workshop.py b/test/integrationtests/test_workshop.py index b3840093ce6c..27bdc9be6dae 100644 --- a/test/integrationtests/test_workshop.py +++ b/test/integrationtests/test_workshop.py @@ -106,7 +106,7 @@ def test_skills_abort_event(self): speak_msg = {'type': 'speak', 'data': {'utterance': 'still here', 'expect_response': False, 'meta': {'skill': 'abort.test'}, - 'lang': 'en-us'}} + 'lang': 'en-US'}} self.assertIn(start_msg, self.bus.emitted_msgs) self.assertIn(speak_msg, self.bus.emitted_msgs) self.assertTrue(self.skill.instance.my_special_var == "changed") @@ -129,7 +129,7 @@ def test_skills_abort_event(self): speak_msg = {'type': 'speak', 'data': {'utterance': 'I am dead', 'expect_response': False, 'meta': {'skill': 'abort.test'}, - 'lang': 'en-us'}} + 'lang': 'en-US'}} self.assertIn(speak_msg, self.bus.emitted_msgs) self.assertTrue(self.skill.instance.my_special_var == "default") @@ -149,7 +149,7 @@ def test_skill_stop(self): 'data': {'name': 'TestAbortSkill.handle_test_abort_intent'}} speak_msg = {'type': 'speak', 'data': {'utterance': 'still here', 'expect_response': False, - 'meta': {'skill': 'abort.test'}, 'lang': 'en-us'}} + 'meta': {'skill': 'abort.test'}, 'lang': 'en-US'}} self.assertIn(start_msg, self.bus.emitted_msgs) self.assertIn(speak_msg, self.bus.emitted_msgs) self.assertTrue(self.skill.instance.my_special_var == "changed") @@ -171,7 +171,7 @@ def test_skill_stop(self): speak_msg = {'type': 'speak', 'data': {'utterance': 'I am dead', 'expect_response': False, 'meta': {'skill': 'abort.test'}, - 'lang': 'en-us'}} + 'lang': 'en-US'}} self.assertIn(speak_msg, self.bus.emitted_msgs) self.assertTrue(self.skill.instance.my_special_var == "default") @@ -198,7 +198,7 @@ def test_get_response(self): 'data': {'utterance': 'this is a question', 'expect_response': True, 'meta': {'dialog': 'question', 'data': {}, 'skill': 'abort.test'}, - 'lang': 'en-us'}} + 'lang': 'en-US'}} activate_msg = {'type': 'intent.service.skills.activate', 'data': {'skill_id': 'abort.test'}} self.assertIn(start_msg, self.bus.emitted_msgs) @@ -219,7 +219,7 @@ def test_get_response(self): 'data': {'utterance': 'question aborted', 'expect_response': False, 'meta': {'skill': 'abort.test'}, - 'lang': 'en-us'}} + 'lang': 'en-US'}} self.assertIn(speak_msg, self.bus.emitted_msgs) def test_developer_stop_msg(self): @@ -236,7 +236,7 @@ def test_developer_stop_msg(self): 'data': {'utterance': "you can't abort me", 'expect_response': False, 'meta': {'skill': 'abort.test'}, - 'lang': 'en-us'}} + 'lang': 'en-US'}} self.assertIn(start_msg, self.bus.emitted_msgs) self.assertIn(speak_msg, self.bus.emitted_msgs) @@ -265,7 +265,7 @@ def test_developer_stop_msg(self): speak_msg = {'type': 'speak', 'data': {'utterance': 'I am dead', 'expect_response': False, 'meta': {'skill': 'abort.test'}, - 'lang': 'en-us'}} + 'lang': 'en-US'}} self.assertIn(speak_msg, self.bus.emitted_msgs) self.assertTrue(self.skill.instance.my_special_var == "default") diff --git a/test/unittests/test_intent_service.py b/test/unittests/test_intent_service.py index 023392e79fff..bef2a35143c8 100644 --- a/test/unittests/test_intent_service.py +++ b/test/unittests/test_intent_service.py @@ -31,7 +31,7 @@ NO_LANG_CONF = deepcopy(LocalConf(DEFAULT_CONFIG)) NO_LANG_CONF.pop('lang') -setup_locale("en-us") +setup_locale("en-US") class MockEmitter(object): @@ -103,17 +103,17 @@ def test_no_lang_in_message(self): """No lang in message should result in lang from active locale.""" setup_locale("it-it") msg = Message('test msg', data={}) - self.assertEqual(get_message_lang(msg), 'it-it') - setup_locale("en-us") - self.assertEqual(get_message_lang(msg), 'en-us') + self.assertEqual(get_message_lang(msg), 'it-IT') + setup_locale("en-US") + self.assertEqual(get_message_lang(msg), 'en-US') @mock.patch.dict(Configuration._Configuration__patch, BASE_CONF) def test_lang_exists(self): """Message has a lang code in data, it should be used.""" msg = Message('test msg', data={'lang': 'de-de'}) - self.assertEqual(get_message_lang(msg), 'de-de') + self.assertEqual(get_message_lang(msg), 'de-DE') msg = Message('test msg', data={'lang': 'sv-se'}) - self.assertEqual(get_message_lang(msg), 'sv-se') + self.assertEqual(get_message_lang(msg), 'sv-SE') def create_old_style_vocab_msg(keyword, value): diff --git a/test/unittests/xformers.py b/test/unittests/xformers.py index f64104eb7e8e..3f248e77e6da 100644 --- a/test/unittests/xformers.py +++ b/test/unittests/xformers.py @@ -67,7 +67,7 @@ def test_utterance_transformer_service_transform(self): def test_utterance_transformer_service_priority(self): utterances = ["test 1", "test one"] - lang = "en-us" + lang = "en-US" def mod_1_parse(utterances, lang): utterances.append("mod 1 parsed") From e5cea977c3881553a85e671c8eb9d477ae4c7946 Mon Sep 17 00:00:00 2001 From: JarbasAl Date: Wed, 16 Oct 2024 03:12:58 +0000 Subject: [PATCH 2/3] Increment Version to 0.2.4a1 --- ovos_core/version.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ovos_core/version.py b/ovos_core/version.py index 22edf8e5c4c9..f1ef6e38f42f 100644 --- a/ovos_core/version.py +++ b/ovos_core/version.py @@ -1,8 +1,8 @@ # START_VERSION_BLOCK VERSION_MAJOR = 0 VERSION_MINOR = 2 -VERSION_BUILD = 3 -VERSION_ALPHA = 0 +VERSION_BUILD = 4 +VERSION_ALPHA = 1 # END_VERSION_BLOCK # for compat with old imports From 8e82b76456fac384317758fb5dd60a440416825c Mon Sep 17 00:00:00 2001 From: JarbasAl Date: Wed, 16 Oct 2024 03:13:39 +0000 Subject: [PATCH 3/3] Update Changelog --- CHANGELOG.md | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d44a9465f5b..c4626eae490f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,20 +1,12 @@ # Changelog -## [0.2.3a1](https://github.com/OpenVoiceOS/ovos-core/tree/0.2.3a1) (2024-10-15) +## [0.2.4a1](https://github.com/OpenVoiceOS/ovos-core/tree/0.2.4a1) (2024-10-16) -[Full Changelog](https://github.com/OpenVoiceOS/ovos-core/compare/0.2.2a1...0.2.3a1) +[Full Changelog](https://github.com/OpenVoiceOS/ovos-core/compare/0.2.3...0.2.4a1) **Merged pull requests:** -- fix:log\_spam [\#566](https://github.com/OpenVoiceOS/ovos-core/pull/566) ([JarbasAl](https://github.com/JarbasAl)) - -## [0.2.2a1](https://github.com/OpenVoiceOS/ovos-core/tree/0.2.2a1) (2024-10-15) - -[Full Changelog](https://github.com/OpenVoiceOS/ovos-core/compare/0.2.1...0.2.2a1) - -**Merged pull requests:** - -- deprecate ready setting [\#554](https://github.com/OpenVoiceOS/ovos-core/pull/554) ([JarbasAl](https://github.com/JarbasAl)) +- fix:standardize\_lang [\#568](https://github.com/OpenVoiceOS/ovos-core/pull/568) ([JarbasAl](https://github.com/JarbasAl))