From 0c4e9fc05f9774f2ac31c5c8f8641693eff3dde3 Mon Sep 17 00:00:00 2001 From: bel Date: Sat, 25 Mar 2023 20:44:35 -0600 Subject: [PATCH] reactor to stdout --- whisper-2023/hotwords.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/whisper-2023/hotwords.py b/whisper-2023/hotwords.py index 9c9c23d..674b4b1 100644 --- a/whisper-2023/hotwords.py +++ b/whisper-2023/hotwords.py @@ -14,13 +14,9 @@ def main(): Manager(managerToParserQ), Reader(managerToParserQ, readerToParserQ), Parser(readerToParserQ, parserToReactorQ), + Reactor(parserToReactorQ), ] [t.start() for t in threads] - while True: - got = parserToReactorQ.get() - if not got: - break - print(got) [t.join() for t in threads] def log(*args): @@ -100,5 +96,20 @@ class Parser(threading.Thread): r = sr.Recognizer() return r.recognize_whisper(clip, language="english") + +class Reactor(threading.Thread): + def __init__(self, inq): + threading.Thread.__init__(self) + self.inq = inq + + def run(self): + log("Reactor.run: start") + while True: + got = self.inq.get() + if not got: + break + print(got) + log("Reactor.run: stop") + if __name__ == "__main__": main()