Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/lang_plugs_fallback #18

Merged
merged 2 commits into from
Mar 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions ovos_plugin_manager/language.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ def create(config=None):
lang_module = OVOSLangDetectionFactory.MAPPINGS[lang_module]

clazz = load_lang_detect_plugin(lang_module)
if clazz is None and lang_module != "libretranslate_detection_plug":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this fallback be configurable or at least spec'd in some internal variable?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree, it should read from mycroft.conf (via ovos_utils to account for ovos.conf)

we should also install the default plugin in requirements, probably worth a discussion about what this should be

ideally we want detect and translate to match (so we only add 1 dependency) and to be offline, however there are no good offline translation options

libretranslate is self hosted and makes sense to use, but it introduces latency, maybe detecting could use something like fast lang by default?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like libretranslate as a default since it's free and reliable. I don't think detection should be necessary very often since we should generally have language specified

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

often detection is done before translation to see if it is necessary, arguably whatever is doing that could be refactored to check for langparam,

regardless at OPM level we should assume lang is never present, that is a concern of core/skills

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True; I think using lang when it's available will help performance regardless (both speed and accuracy) but we will need to detect in some casts.. I like reducing default dependencies as much as possible, but I'm fine with adding fastlang if there's a performance benefit

lang_module = "libretranslate_detection_plug"
LOG.error(f'Language Translation plugin {lang_module} not found\n'
f'Falling back to libretranslate plugin')
clazz = load_tx_plugin("libretranslate_detection_plug")
if clazz is None:
raise ValueError(f'Language Detection plugin {lang_module} not found')
LOG.info(f'Loaded the Language Detection plugin {lang_module}')
Expand Down Expand Up @@ -87,11 +92,15 @@ def create(config=None):
config = config or read_mycroft_config()
if "language" in config:
config = config["language"]
lang_module = config.get("translation_module", "libretranslate_detection_plug")
lang_module = config.get("translation_module", "libretranslate_plug")
if lang_module in OVOSLangDetectionFactory.MAPPINGS:
lang_module = OVOSLangDetectionFactory.MAPPINGS[lang_module]

clazz = load_tx_plugin(lang_module)
if clazz is None and lang_module != "libretranslate_plug":
lang_module = "libretranslate_plug"
LOG.error(f'Language Translation plugin {lang_module} not found\n'
f'Falling back to libretranslate plugin')
clazz = load_tx_plugin("libretranslate_plug")
if clazz is None:
raise ValueError(f'Language Translation plugin {lang_module} not found')
LOG.info(f'Loaded the Language Translation plugin {lang_module}')
Expand Down