timer_funktion funktioniert grob
This commit is contained in:
57
main.py
57
main.py
@@ -7,6 +7,8 @@ import subprocess
|
||||
import sounddevice as sd
|
||||
import re
|
||||
import asyncio
|
||||
from weather_jetzt import get_weather_for_location
|
||||
from timer_control import parse_time, start_timer, stop_timer, timer_status_info, format_duration
|
||||
|
||||
#test
|
||||
|
||||
@@ -88,7 +90,9 @@ INTENTS = {
|
||||
"start": {
|
||||
"keywords": ["starte", "start", "beginne", "stelle"],
|
||||
"required_slots": {
|
||||
"duration": r"(\w+)\s*(sekunden|sekunde|minuten|minute|stunden|stunde)"
|
||||
# "duration": r"(\w+)\s*(sekunden|sekunde|minuten|minute|stunden|stunde)"
|
||||
"duration": r"((?:\w+)\s*(?:sekunden|sekunde|minuten|minute|stunden|stunde))"
|
||||
|
||||
}
|
||||
},
|
||||
"stop": {
|
||||
@@ -117,7 +121,7 @@ def detect_intent(text):
|
||||
# SKILLS
|
||||
# =========================
|
||||
|
||||
from weather_jetzt import get_weather_for_location
|
||||
|
||||
|
||||
def weather_skill(slots):
|
||||
location = slots["location"]
|
||||
@@ -131,13 +135,33 @@ def weather_skill(slots):
|
||||
|
||||
def start_timer_skill(slots):
|
||||
duration = slots["duration"]
|
||||
return f"Der Timer für {duration} Minuten wurde gestartet."
|
||||
seconds = parse_time(duration)
|
||||
if seconds:
|
||||
start_timer(seconds)
|
||||
return f"Timer gestartet"
|
||||
# return f"Der Timer für {duration} wurde gestartet."
|
||||
|
||||
def stopp_timer_skill(slots):
|
||||
return f"Timer wurde gestoppt."
|
||||
#return f"Timer wurde gestoppt."
|
||||
stop_timer()
|
||||
return f"Timer wurde gestoppt"
|
||||
|
||||
def status_timer_skill(slots):
|
||||
return f"Status Timer Ausgabe"
|
||||
# remaining = timer_status_info()["remaining"]
|
||||
# return f"Status Timer Ausgabe {remaining}"
|
||||
|
||||
info = timer_status_info()
|
||||
|
||||
if info["status"] == "running":
|
||||
remaining = info["remaining"]
|
||||
return f"Der Timer läuft noch {format_duration(remaining)} "
|
||||
elif info["status"] == "finished":
|
||||
return f"Der Timer ist abgelaufen"
|
||||
elif info["status"] == "stopped":
|
||||
return f"Der Timer wurde gestoppt"
|
||||
else:
|
||||
return f"Es läuft kein Timer"
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -258,13 +282,14 @@ def reset_context():
|
||||
"pending_slot": None,
|
||||
"action": None
|
||||
}
|
||||
state = STATE_IDLE
|
||||
#state = STATE_IDLE
|
||||
state = STATE_LISTENING
|
||||
|
||||
|
||||
# =========================
|
||||
# VOSK LISTENER
|
||||
# =========================
|
||||
|
||||
"""
|
||||
def vosk_listener():
|
||||
SAMPLE_RATE_VOSK = 16000
|
||||
from vosk import Model, KaldiRecognizer
|
||||
@@ -294,7 +319,7 @@ def vosk_listener():
|
||||
else:
|
||||
rec.Reset()
|
||||
|
||||
|
||||
"""
|
||||
# =========================
|
||||
# WAKEWORD (SIMPLIFIZIERT)
|
||||
# =========================
|
||||
@@ -310,6 +335,8 @@ def fake_wakeword_detector():
|
||||
# ==========================
|
||||
# WAKEWORD (PORCUPINE)
|
||||
# ==========================
|
||||
|
||||
"""
|
||||
def real_wakeword_detector():
|
||||
import pvporcupine
|
||||
import numpy as np
|
||||
@@ -347,12 +374,12 @@ def real_wakeword_detector():
|
||||
while True:
|
||||
pass
|
||||
|
||||
|
||||
"""
|
||||
# =========================
|
||||
# MAIN LOOP
|
||||
# =========================
|
||||
|
||||
def main():
|
||||
""" def main():
|
||||
threading.Thread(target=vosk_listener, daemon=True).start()
|
||||
# threading.Thread(target=fake_wakeword_detector, daemon=True).start()
|
||||
threading.Thread(target=real_wakeword_detector, daemon=True).start()
|
||||
@@ -362,7 +389,15 @@ def main():
|
||||
text = audio_queue.get(timeout=0.1)
|
||||
handle_text(text)
|
||||
except queue.Empty:
|
||||
pass
|
||||
pass """
|
||||
|
||||
def main():
|
||||
global state
|
||||
state = STATE_LISTENING
|
||||
while True:
|
||||
text = input("Text input: ")
|
||||
handle_text(text)
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user