From 7b948244fab52adf9bcfb661244d2fdc1728209c Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 8 Feb 2026 17:39:24 +0000 Subject: [PATCH] server_microphone.py aktualisiert --- server_microphone.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/server_microphone.py b/server_microphone.py index c628efa..2b6bccc 100644 --- a/server_microphone.py +++ b/server_microphone.py @@ -20,6 +20,9 @@ import subprocess global activation_word activation_word = "erwin" +global run_stop_only_once_flag +run_stop_only_once_flag = True + def int_or_str(text): """Helper function for argument parsing.""" try: @@ -46,50 +49,57 @@ async def run_test(): await websocket.send(data) finalResult = await websocket.recv() print(finalResult) - if "licht" in finalResult and "an" in finalResult and activation_word in finalResult and "result" in finalResult: + if "licht" in finalResult and "an" in finalResult and activation_word in finalResult and run_stop_only_once_flag: print("SCHALTER EIN!") pixels.wakeup() time.sleep(1) pixels.off() avm_sid.lights_on() - if "licht" in finalResult and "aus" in finalResult and activation_word in finalResult and "result" in finalResult: + run_stop_only_once_flag = False + if "licht" in finalResult and "aus" in finalResult and activation_word in finalResult and run_stop_only_once_flag: print("SCHALTER AUS!") pixels.wakeup() time.sleep(1) pixels.off() avm_sid.lights_off() - if "blinken" in finalResult and activation_word in finalResult and "result" in finalResult: + run_stop_only_once_flag = False + if "blinken" in finalResult and activation_word in finalResult and run_stop_only_once_flag: print("Blinken!") pixels.wakeup() time.sleep(2) pixels.off() - if "nachrichten" in finalResult and activation_word in finalResult and "result" in finalResult: + run_stop_only_once_flag = False + if "nachrichten" in finalResult and activation_word in finalResult and run_stop_only_once_flag: pixels.wakeup() time.sleep(1) pixels.off() subprocess.Popen(["sh", "/home/pi/tagesschau/start_news.sh"]) - if "saarland" in finalResult and activation_word in finalResult and "result" in finalResult: + run_stop_only_once_flag = False + if "saarland" in finalResult and activation_word in finalResult and run_stop_only_once_flag: pixels.wakeup() time.sleep(1) pixels.off() - subprocess.Popen(["sh", "/home/pi/tagesschau/start_news.sh"]) - if "nova" in finalResult and activation_word in finalResult and "result" in finalResult: + subprocess.Popen(["sh", "/home/pi/tagesschau/start_platt.sh"]) + run_stop_only_once_flag = False + if "nova" in finalResult and activation_word in finalResult and run_stop_only_once_flag: pixels.wakeup() time.sleep(1) pixels.off() subprocess.Popen(["sh", "/home/pi/radio/start_nova.sh"]) - if "funk" in finalResult and activation_word in finalResult and "result" in finalResult: + run_stop_only_once_flag = False + if "funk" in finalResult and activation_word in finalResult and run_stop_only_once_flag: pixels.wakeup() time.sleep(1) pixels.off() subprocess.Popen(["sh", "/home/pi/radio/start_dlf.sh"]) + run_stop_only_once_flag = False if ("stop" in finalResult or "stopp" in finalResult) and activation_word in finalResult and run_stop_only_once_flag: pixels.wakeup() time.sleep(1) pixels.off() subprocess.Popen(["sh", "/home/pi/tagesschau/end_news.sh"]) run_stop_only_once_flag = False - if ("stop" in finalResult or "stopp" in finalResult) and "result" in finalResult: + if "result" in finalResult: run_stop_only_once_flag = True async def main():