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/vad plugins #40

Merged
merged 2 commits into from
Mar 5, 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
22 changes: 11 additions & 11 deletions ovos_plugin_manager/vad.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from ovos_plugin_manager.utils import load_plugin, find_plugins, PluginTypes
from ovos_utils.configuration import read_mycroft_config
from ovos_utils.log import LOG
from ovos_plugin_manager.templates.vad import VAD
from ovos_plugin_manager.templates.vad import VADEngine


def find_vad_plugins():
Expand Down Expand Up @@ -38,9 +38,9 @@ def get_class(config=None):
}
"""
config = config or get_vad_config()
vad_module = config["module"]
vad_module = config.get("module", "dummy")
if vad_module == "dummy":
return VAD
return VADEngine
if vad_module in OVOSVADFactory.MAPPINGS:
vad_module = OVOSVADFactory.MAPPINGS[vad_module]
return load_vad_plugin(vad_module)
Expand All @@ -57,22 +57,22 @@ def create(config=None):
}
"""
config = config or get_vad_config()
plugin = config["module"]
plugin_config = config[plugin]
plugin = config.get("module") or "dummy"
plugin_config = config.get(plugin) or {}
try:
clazz = OVOSVADFactory.get_class(config)
return clazz(plugin_config)
except Exception:
LOG.exception('The selected VAD plugin could not be loaded!')
LOG.error(f'VAD plugin {plugin} could not be loaded!')
raise


def get_vad_config(config=None):
config = config or read_mycroft_config()
lang = config.get("lang", "en-us")
if "vad" in config:
config = config["vad"]
vad_module = config.get('module', 'dummy')
if "listener" in config and "VAD" not in config:
config = config["listener"] or {}
if "VAD" in config:
config = config["VAD"]
vad_module = config.get('module') or 'dummy'
vad_config = config.get(vad_module, {})
vad_config["lang"] = vad_config.get('lang') or lang
return vad_config