From 20afbeb12291807890ea7ea6474489d710eed5a2 Mon Sep 17 00:00:00 2001 From: void Date: Sun, 18 Jan 2026 20:33:37 +0100 Subject: [PATCH] Einfache Regex Check Demo --- main.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 9055f03..812bf58 100644 --- a/main.py +++ b/main.py @@ -5,6 +5,7 @@ import time import os import subprocess import sounddevice as sd +import re #test @@ -12,7 +13,7 @@ import sounddevice as sd # KONFIGURATION # ========================= -VOSK_MODEL_PATH = "/home/tino/Desktop/Abschlussprojekt/test assistant/cloneAssistantAllInOne/RasPi_Voice_Assistant--WIP/vosk-model-de-0.21" +VOSK_MODEL_PATH = "/home/tino/Desktop/Abschlussprojekt/test assistant/cloneAssistantAllInOne/vosk-model-de-0.21/" PIPER_BIN = "piper" PIPER_MODEL = "de_DE-thorsten-medium.onnx" SAMPLE_RATE = 22050 @@ -102,6 +103,7 @@ def timer_skill(slots): duration = slots["duration"] return f"Der Timer für {duration} Minuten wurde gestartet." + SKILLS = { "weather": weather_skill, "timer": timer_skill @@ -135,6 +137,8 @@ def handle_text(text): context["intent"] = intent context["required_slots"] = INTENTS[intent]["required_slots"] + check_required(text) + # 3. Fehlende Slots prüfen for slot in context["required_slots"]: if slot not in context["slots"]: @@ -147,6 +151,24 @@ def handle_text(text): speak(result) reset_context() +def check_required(text): + if context["intent"] == "weather" or context["pending_slot"] != None: + if not re.search(r'in\b', text): + print("LOCATION ABFRAGEN") + + else: + print("LOCATION ERMITTELN") + context["pending_slot"] = None + + elif context["intent"] == "timer": + if not re.search(r'\b(sekunde|minute|stunde)n?\b', text): + print("DURATION ABFRAGEN") + else: + print("DURATION ERMITTELN") + context["pending_slot"] = None + + + def ask_for_slot(slot): questions = {