Skip to content

Commit

Permalink
Merge pull request #298 from OpenVoiceOS/release-3.0.1a1
Browse files Browse the repository at this point in the history
Release 3.0.1a1
  • Loading branch information
JarbasAl authored Nov 19, 2024
2 parents a478c29 + 82f7af2 commit a21ec16
Show file tree
Hide file tree
Showing 27 changed files with 36 additions and 24 deletions.
10 changes: 3 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
# Changelog

## [3.0.0a1](https://github.com/OpenVoiceOS/OVOS-workshop/tree/3.0.0a1) (2024-11-19)
## [3.0.1a1](https://github.com/OpenVoiceOS/OVOS-workshop/tree/3.0.1a1) (2024-11-19)

[Full Changelog](https://github.com/OpenVoiceOS/OVOS-workshop/compare/2.4.4...3.0.0a1)

**Breaking changes:**

- deprecate!:backend client [\#295](https://github.com/OpenVoiceOS/OVOS-workshop/pull/295) ([JarbasAl](https://github.com/JarbasAl))
[Full Changelog](https://github.com/OpenVoiceOS/OVOS-workshop/compare/3.0.0...3.0.1a1)

**Merged pull requests:**

- Create skill.error.dialog nl-nl [\#294](https://github.com/OpenVoiceOS/OVOS-workshop/pull/294) ([timonvanhasselt](https://github.com/timonvanhasselt))
- fix:bundled\_resources [\#297](https://github.com/OpenVoiceOS/OVOS-workshop/pull/297) ([JarbasAl](https://github.com/JarbasAl))



Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions ovos_workshop/locale/en/cancel.voc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cancel
nevermind
forget it
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 18 additions & 7 deletions ovos_workshop/resource_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@
from typing import List, Optional, Tuple, Dict, Any

from langcodes import tag_distance
from ovos_config.config import Configuration
from ovos_config.locations import get_xdg_data_save_path
from ovos_utils import flatten_list
from ovos_utils.bracket_expansion import expand_options
from ovos_utils.dialog import MustacheDialogRenderer, load_dialogs
from ovos_utils.log import LOG, log_deprecation
from ovos_utils.log import LOG

SkillResourceTypes = namedtuple(
"SkillResourceTypes",
Expand Down Expand Up @@ -164,6 +163,14 @@ def __init__(self, resource_type: str, file_extension: str,
self.language = language
self.base_directory = None
self.user_directory = None
self.workshop_directory = None

def locate_workshop_directory(self):
if not self.language:
return
for path in locate_lang_directories(self.language, dirname(__file__)):
self.workshop_directory = path
return

def locate_lang_directories(self, skill_directory):
if not self.language:
Expand Down Expand Up @@ -300,6 +307,13 @@ def _locate(self) -> Optional[str]:
if file_name in file_names:
file_path = Path(directory, file_name)

# check ovos-workshop resources
if file_path is None and self.resource_type.workshop_directory is not None:
walk_directory = str(self.resource_type.workshop_directory)
for directory, _, file_names in walk(walk_directory):
if file_name in file_names:
file_path = Path(directory, file_name)

if file_path is None:
LOG.debug(f"Could not find resource file {file_name} for lang: {self.resource_type.language}")

Expand Down Expand Up @@ -602,6 +616,7 @@ def _define_resource_types(self) -> SkillResourceTypes:
if self.skill_id:
resource_type.locate_user_directory(self.skill_id)
resource_type.locate_base_directory(self.skill_directory)
resource_type.locate_workshop_directory()
return SkillResourceTypes(**resource_types)

def load_json_file(self, name: str = "skill.json") -> Dict[str, str]:
Expand Down Expand Up @@ -882,11 +897,7 @@ def _make_unique_regex_group(regexes: List[str],

class CoreResources(SkillResources):
def __init__(self, language):
try:
from mycroft import MYCROFT_ROOT_PATH
directory = f"{MYCROFT_ROOT_PATH}/mycroft/res"
except ImportError:
directory = f"{dirname(__file__)}/res"
directory = f"{dirname(__file__)}/locale"
super().__init__(directory, language)


Expand Down
2 changes: 1 addition & 1 deletion ovos_workshop/skills/common_query_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __init__(self, *args, **kwargs):

lang = self.lang.split("-")[0]
noise_words_filepath = f"text/{lang}/noise_words.list"
default_res = f"{dirname(dirname(__file__))}/res/text/{lang}" \
default_res = f"{dirname(dirname(__file__))}/locale/{lang}" \
f"/noise_words.list"
noise_words_filename = \
resolve_resource_file(noise_words_filepath,
Expand Down
16 changes: 9 additions & 7 deletions ovos_workshop/skills/ovos.py
Original file line number Diff line number Diff line change
Expand Up @@ -1842,7 +1842,7 @@ def on_fail_default(utterance):
return dialog

def is_cancel(utterance):
return self.voc_match(utterance, 'cancel')
return self.voc_match(utterance, 'cancel', lang=session.lang)

def validator_default(utterance):
# accept anything except 'cancel'
Expand Down Expand Up @@ -2122,13 +2122,13 @@ def voc_match(self, utt: str, voc_filename: str, lang: Optional[str] = None,
requested.
The method first checks in the current Skill's .voc files and secondly
in the "res/text" folder of mycroft-core. The result is cached to
in the "locale" folder of ovos-workshop. The result is cached to
avoid hitting the disk each time the method is called.
Args:
utt (str): Utterance to be tested
voc_filename (str): Name of vocabulary file (e.g. 'yes' for
'res/text/en-us/yes.voc')
voc_filename (str): Name of vocabulary file (e.g. 'cancel' for
'locale/en-us/cancel.voc')
lang (str): Language code, defaults to self.lang
exact (bool): Whether the vocab must exactly match the utterance
Expand Down Expand Up @@ -2527,10 +2527,11 @@ def _get_dialog(phrase: str, lang: str, context: Optional[dict] = None) -> str:
Returns:
str: a randomized and/or translated version of the phrase
"""
filename = f"{dirname(dirname(__file__))}/res/text/{lang.split('-')[0]}/{phrase}.dialog"
lang = standardize_lang_tag(lang).split('-')[0]
filename = f"{dirname(dirname(__file__))}/locale/{lang}/{phrase}.dialog"

if not isfile(filename):
LOG.debug('Resource file not found: {}'.format(filename))
LOG.debug(f'Resource file not found: {filename}')
return phrase

stache = MustacheDialogRenderer()
Expand All @@ -2550,7 +2551,8 @@ def _get_word(lang, connector):
Returns:
str: translated version of resource name
"""
res_file = f"{dirname(dirname(__file__))}/res/text/{lang}" \
lang = standardize_lang_tag(lang).split("-")[0]
res_file = f"{dirname(dirname(__file__))}/locale/{lang}" \
f"/word_connectors.json"
if not os.path.isfile(res_file):
LOG.warning(f"untranslated file: {res_file}")
Expand Down
4 changes: 2 additions & 2 deletions ovos_workshop/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# START_VERSION_BLOCK
VERSION_MAJOR = 3
VERSION_MINOR = 0
VERSION_BUILD = 0
VERSION_ALPHA = 0
VERSION_BUILD = 1
VERSION_ALPHA = 1
# END_VERSION_BLOCK

0 comments on commit a21ec16

Please sign in to comment.