From 6282972374d21dafb995ee416ec6e6abf3ffe06f Mon Sep 17 00:00:00 2001 From: bel Date: Sat, 25 Mar 2023 21:28:27 -0600 Subject: [PATCH] load but dont use hotwords from $REACTOR_HOTWORDS --- whisper-2023/hotwords.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/whisper-2023/hotwords.py b/whisper-2023/hotwords.py index 93b6f85..714b461 100644 --- a/whisper-2023/hotwords.py +++ b/whisper-2023/hotwords.py @@ -104,6 +104,25 @@ class Reactor(threading.Thread): threading.Thread.__init__(self) self.inq = inq self.outq = outq + self.load_hotwords = Reactor.new_load_hotwords + self.load_hotwords() + + def new_load_hotwords(): + p = environ.get("REACTOR_HOTWORDS", None) + if not p: + return lambda: [] + + try: + def load_hotwords_in_file(): + with open(p, "r") as f: + return ["".join(i.strip().lower().split()) for i in f.readlines()] + return load_hotwords_in_file + except Exception: + pass + + def load_hotwords_as_literal(): + return ["".join(i.strip().split()) for i in p.lower().split(",")] + return load_hotwords_as_literal def run(self): log("Reactor.run: start") @@ -116,6 +135,7 @@ class Reactor(threading.Thread): log("Reactor.run: stop") def handle(self, text): + hotwords = self.load_hotwords() print(text) class Actor(threading.Thread):