From b4d3e5a27cbdecfd70f6601d7b51ab9a07a045f7 Mon Sep 17 00:00:00 2001 From: bel Date: Wed, 19 Apr 2023 18:24:07 -0600 Subject: [PATCH] HOTWORDS yaml @ can have comma delimited and KEYS --- rust-whisper.d/hotwords.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/rust-whisper.d/hotwords.py b/rust-whisper.d/hotwords.py index 13ee1ec..42e0d8b 100644 --- a/rust-whisper.d/hotwords.py +++ b/rust-whisper.d/hotwords.py @@ -185,6 +185,8 @@ def _load_dot_notation(v, items): else: result.append(subresult) return result + elif k == "KEYS": + v = [k for k in v] else: if isinstance(v, list): v = v[int(k)] @@ -229,8 +231,15 @@ class Reactor(threading.Thread): def load_hotwords_in_yaml_file(): with open(p.split("@")[0], "r") as f: v = yaml.safe_load(f) - v = load_dot_notation(v, p.split("@")[-1]) - return ["".join(i.strip().lower().split()) for i in v if i] + if os.environ.get("DEBUG", None): + log(f'opened {p.split("@")[0]} and got {v}') + result = [] + for to_find in [i for i in p.split("@")[-1].split(",") if i]: + if os.environ.get("DEBUG", None): + log(f'finding {to_find} in {v}') + v2 = load_dot_notation(v, to_find) + result.extend(["".join(i.strip().lower().split()) for i in v2 if i]) + return result load_hotwords_in_yaml_file() return load_hotwords_in_yaml_file else: