diff --git a/whisper-2023/hotwords.py b/whisper-2023/hotwords.py index 130e14c..2239861 100644 --- a/whisper-2023/hotwords.py +++ b/whisper-2023/hotwords.py @@ -6,6 +6,7 @@ import signal import sys from os import environ from os import kill +import requests def main(): managerToParserQ = queue.Queue(maxsize=1) @@ -176,6 +177,9 @@ class Actor(threading.Thread): elif environ.get("SIGUSR2", ""): self.pid = int(environ["SIGUSR2"]) self.handle = self.handle_signal + elif environ.get("URL", ""): + self.url = environ["URL"] + self.handle = self.handle_url def run(self): log("Actor.run: start") @@ -197,5 +201,12 @@ class Actor(threading.Thread): self.handle_stderr(hotword, context) kill(self.pid, signal.SIGUSR2) + def handle_url(self, hotword, context): + self.handle_stderr(hotword, context) + try: + requests.post(self.url, json={"hotword":hotword, "context":context}) + except Exception as e: + log("Actor.handle_url:", e) + if __name__ == "__main__": main()