diff --git a/whisper-2023/hotwords.py b/whisper-2023/hotwords.py index 714b461..f7e9d4d 100644 --- a/whisper-2023/hotwords.py +++ b/whisper-2023/hotwords.py @@ -104,13 +104,15 @@ class Reactor(threading.Thread): threading.Thread.__init__(self) self.inq = inq self.outq = outq - self.load_hotwords = Reactor.new_load_hotwords - self.load_hotwords() + self.load_hotwords = Reactor.new_load_hotwords() + [i for i in self.load_hotwords()] def new_load_hotwords(): - p = environ.get("REACTOR_HOTWORDS", None) + p = environ.get("HOTWORDS", None) if not p: - return lambda: [] + def load_nothing(): + return [] + return load_nothing try: def load_hotwords_in_file(): @@ -136,7 +138,14 @@ class Reactor(threading.Thread): def handle(self, text): hotwords = self.load_hotwords() - print(text) + if not hotwords: + self.outq.put(text) + return + cleantext = "".join([i for i in "".join(text.lower().split()) if i.isalpha()]) + for i in hotwords: + if i in cleantext: + log("hotword", i, "in", text, "as", cleantext) + self.outq.put(i) class Actor(threading.Thread): def __init__(self, inq):