|
13 | 13 | import json |
14 | 14 | import random |
15 | 15 | import subprocess |
| 16 | +import time |
| 17 | +import warnings |
16 | 18 | import wave |
17 | 19 | from enum import Enum |
18 | 20 | from hashlib import md5 |
|
24 | 26 | from typing import List, Tuple, Optional, Union |
25 | 27 |
|
26 | 28 | import speech_recognition as sr |
27 | | -import time |
28 | 29 | from ovos_bus_client import MessageBusClient |
29 | 30 | from ovos_bus_client.message import Message |
30 | 31 | from ovos_bus_client.session import SessionManager |
|
37 | 38 | from ovos_plugin_manager.templates.vad import VADEngine |
38 | 39 | from ovos_plugin_manager.utils.tts_cache import hash_sentence |
39 | 40 | from ovos_plugin_manager.vad import OVOSVADFactory, get_vad_configs |
| 41 | +from ovos_plugin_manager.wakewords import find_wake_word_verifier_plugins |
40 | 42 | from ovos_plugin_manager.wakewords import get_ww_lang_configs, get_ww_supported_langs, get_ww_module_configs |
41 | 43 | from ovos_utils.fakebus import FakeBus |
42 | 44 | from ovos_utils.log import LOG, log_deprecation |
43 | 45 | from ovos_utils.process_utils import ProcessStatus, StatusCallbackMap, ProcessState |
| 46 | +from ovos_utils.sound import get_sound_duration |
44 | 47 |
|
45 | | -import warnings |
46 | 48 | from ovos_dinkum_listener._util import _TemplateFilenameFormatter |
47 | 49 | from ovos_dinkum_listener.plugins import load_stt_module, load_fallback_stt, FakeStreamingSTT |
48 | 50 | from ovos_dinkum_listener.transformers import AudioTransformersService |
49 | 51 | from ovos_dinkum_listener.voice_loop import DinkumVoiceLoop, ListeningMode, ListeningState |
50 | 52 | from ovos_dinkum_listener.voice_loop.hotwords import HotwordContainer |
51 | 53 |
|
52 | | - |
53 | | -try: |
54 | | - from ovos_utils.sound import get_sound_duration |
55 | | -except ImportError: |
56 | | - |
57 | | - def get_sound_duration(*args, **kwargs): |
58 | | - raise ImportError("please install ovos-utils>=0.1.0a25") |
59 | | - |
60 | 54 | # Seconds between systemd watchdog updates |
61 | 55 | WATCHDOG_DELAY = 0.5 |
62 | 56 |
|
@@ -194,7 +188,25 @@ def __init__(self, on_ready=on_ready, on_error=on_error, |
194 | 188 |
|
195 | 189 | self.mic = mic or OVOSMicrophoneFactory.create(microphone_config) |
196 | 190 |
|
197 | | - self.hotwords = hotwords or HotwordContainer(self.bus) |
| 191 | + verifiers_cfg = self.config.get("listener", {}).get("ww_verifiers", {}) |
| 192 | + verifier_plugs = {} |
| 193 | + for plug_type, plug in find_wake_word_verifier_plugins().items(): |
| 194 | + cfg = verifiers_cfg.get(plug_type, {}) |
| 195 | + if not cfg.get("enabled", True): # plugins are enabled by default if installed, unless disabled in config |
| 196 | + LOG.debug(f"wakeword verifier plugin disabled: {plug_type}") |
| 197 | + continue |
| 198 | + try: |
| 199 | + verifier_plugs[plug_type] = plug(config=cfg) |
| 200 | + except Exception as e: |
| 201 | + LOG.exception(f"Failed to load wakeword verifier plugin: {plug_type}") |
| 202 | + continue |
| 203 | + |
| 204 | + missing_modules = [k for k, v in verifiers_cfg.items() if v.get("active", True) and k not in verifier_plugs] |
| 205 | + if missing_modules: |
| 206 | + LOG.warning(f"wake word verifier plugins enabled in config but not loaded: {missing_modules}") |
| 207 | + LOG.debug(f"Loaded wake word verifier plugins: {list(verifier_plugs)}") |
| 208 | + |
| 209 | + self.hotwords = hotwords or HotwordContainer(bus=self.bus, verifiers=list(verifier_plugs.values())) |
198 | 210 | self.vad = vad or OVOSVADFactory.create() |
199 | 211 | if stt and not isinstance(stt, StreamingSTT): |
200 | 212 | stt = FakeStreamingSTT(stt) |
|
0 commit comments