server_microphone.py aktualisiert
This commit is contained in:
@@ -17,6 +17,8 @@ import avm_sid
|
|||||||
# spawn process for news to run it in a new process
|
# spawn process for news to run it in a new process
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
global activation_word
|
||||||
|
activation_word = "erwin"
|
||||||
|
|
||||||
def int_or_str(text):
|
def int_or_str(text):
|
||||||
"""Helper function for argument parsing."""
|
"""Helper function for argument parsing."""
|
||||||
@@ -44,49 +46,45 @@ async def run_test():
|
|||||||
await websocket.send(data)
|
await websocket.send(data)
|
||||||
finalResult = await websocket.recv()
|
finalResult = await websocket.recv()
|
||||||
print(finalResult)
|
print(finalResult)
|
||||||
if "licht" in finalResult and "an" in finalResult and "hex" in finalResult and "result" in finalResult:
|
if "licht" in finalResult and "an" in finalResult and activation_word in finalResult and "result" in finalResult:
|
||||||
print("SCHALTER EIN!")
|
print("SCHALTER EIN!")
|
||||||
pixels.wakeup()
|
pixels.wakeup()
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
pixels.off()
|
pixels.off()
|
||||||
avm_sid.lights_on()
|
avm_sid.lights_on()
|
||||||
if "licht" in finalResult and "aus" in finalResult and "hex" in finalResult and "result" in finalResult:
|
if "licht" in finalResult and "aus" in finalResult and activation_word in finalResult and "result" in finalResult:
|
||||||
print("SCHALTER AUS!")
|
print("SCHALTER AUS!")
|
||||||
pixels.wakeup()
|
pixels.wakeup()
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
pixels.off()
|
pixels.off()
|
||||||
avm_sid.lights_off()
|
avm_sid.lights_off()
|
||||||
if "blinken" in finalResult and "hex" in finalResult and "result" in finalResult:
|
if "blinken" in finalResult and activation_word in finalResult and "result" in finalResult:
|
||||||
print("Blinken!")
|
print("Blinken!")
|
||||||
pixels.wakeup()
|
pixels.wakeup()
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
pixels.off()
|
pixels.off()
|
||||||
if "nachrichten" in finalResult and "hex" in finalResult and "result" in finalResult:
|
if "nachrichten" in finalResult and activation_word in finalResult and "result" in finalResult:
|
||||||
pixels.wakeup()
|
pixels.wakeup()
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
pixels.off()
|
pixels.off()
|
||||||
#os.system('~/tagesschau/start_news.sh')
|
|
||||||
subprocess.Popen(["sh", "/home/pi/tagesschau/start_news.sh"])
|
subprocess.Popen(["sh", "/home/pi/tagesschau/start_news.sh"])
|
||||||
if "nova" in finalResult and "hex" in finalResult and "result" in finalResult:
|
if "nova" in finalResult and activation_word in finalResult and "result" in finalResult:
|
||||||
pixels.wakeup()
|
pixels.wakeup()
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
pixels.off()
|
pixels.off()
|
||||||
#os.system('~/tagesschau/start_news.sh')
|
|
||||||
subprocess.Popen(["sh", "/home/pi/radio/start_nova.sh"])
|
subprocess.Popen(["sh", "/home/pi/radio/start_nova.sh"])
|
||||||
if "funk" in finalResult and "hex" in finalResult and "result" in finalResult:
|
if "funk" in finalResult and activation_word in finalResult and "result" in finalResult:
|
||||||
pixels.wakeup()
|
pixels.wakeup()
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
pixels.off()
|
pixels.off()
|
||||||
#os.system('~/tagesschau/start_news.sh')
|
|
||||||
subprocess.Popen(["sh", "/home/pi/radio/start_dlf.sh"])
|
subprocess.Popen(["sh", "/home/pi/radio/start_dlf.sh"])
|
||||||
if "ruhe" in finalResult and "hex" in finalResult and run_stop_only_once_flag:
|
if ("stop" in finalResult or "stopp" in finalResult) and activation_word in finalResult and run_stop_only_once_flag:
|
||||||
pixels.wakeup()
|
pixels.wakeup()
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
pixels.off()
|
pixels.off()
|
||||||
#os.system('~/tagesschau/end_news.sh')
|
|
||||||
subprocess.Popen(["sh", "/home/pi/tagesschau/end_news.sh"])
|
subprocess.Popen(["sh", "/home/pi/tagesschau/end_news.sh"])
|
||||||
run_stop_only_once_flag = False
|
run_stop_only_once_flag = False
|
||||||
if "ruhe" in finalResult and "hex" in finalResult and "result" in finalResult:
|
if ("stop" in finalResult or "stopp" in finalResult) and "result" in finalResult:
|
||||||
run_stop_only_once_flag = True
|
run_stop_only_once_flag = True
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
|
|||||||
Reference in New Issue
Block a user