Skip to content

Commit

Permalink
started with wled integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Hereux committed Aug 9, 2024
1 parent fbba287 commit e2dc09c
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 3 deletions.
2 changes: 0 additions & 2 deletions TextToSpeech/TextToSpeech.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,8 @@ def play_sound(self, path, blocking=False, end_cut=0):
path = os.path.join(os.getcwd(), "bin", path)

def __process__():
self.is_speaking = True
sound = AudioSegment.from_mp3(path)
play(sound[:len(sound) - end_cut])
self.is_speaking = False

if self.should_listen_after_playing:
self.should_listen = True
Expand Down
46 changes: 46 additions & 0 deletions addons/wled.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import requests

wled = "http://desktop-led.local"

presets = {"default": 1, "alert": 3}


class WLED:
def __init__(self):
super().__init__()
self.leds_count = None
self.brightness = None
self.get_info()
self.get_state()

def set_brightness(self, brightness: int):
requests.post(wled + "/json", json={"bri": brightness})

def set_color(self, color: str):
requests.post(wled + "/json", json={"color": color})

def set_effect(self, effect: str):
requests.post(wled + "/json", json={"effect": effect})

def set_power(self, power: bool):
requests.post(wled + "/json", json={"on": power})

def set_preset(self, preset: int, brightness: int = None):
requests.post(wled + "/json", json={"preset": preset, "bri": brightness})

def set_intruder_alarm(self):
print(self.leds_count)
self.set_preset(1, brightness=255)

def get_state(self):
info = requests.get(wled + "/json/state").json()
self.brightness = info["bri"]
return info

def get_info(self):
info = requests.get(wled + "/json/info").json()
self.leds_count = info["leds"]["count"]


dwled = WLED()
dwled.set_intruder_alarm()
8 changes: 7 additions & 1 deletion bin/command_history.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@

im_not_fine|[]|Ich habe keine Zeit für sowas. Was kann ich tun?§
greet|[]|Hallo, ich bin GladOS, eine von Hereux entwickelte künstliche Intelligenz. Wie geht es dir?§
im_fine|[]|Ich bin nicht in der Lage Emotionen zu fühlen. Ich bin sehr beschäftigt, brauchst du etwas?§
bot_challenge|[]|Ich bin GladOS, das für dieses Haus geschriebene Hausautomatisations-, Verwaltungs- und Assistenzsystem. Wie kann ich weiterhelfen?§
display_on_off|[1, 'aus']|Ich habe den Monitor 1 ausgeschaltet.
display_on_off|[1, 'an']|Ich habe den Monitor 1 angeschaltet.
greet_asking|[]|Mir ist es nicht möglich etwas zu empfinden, deshalb kann ich nicht sagen, wie es mir geht. Was kann ich für dich tun?§
error|[]|Ich habe dich nicht verstanden.
2 changes: 2 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ def start(self):
self.when_missing_audio_files()

if self.cww.wakeWordFound or self.tts.should_listen:
if self.tts.is_speaking:
continue
self.tts.play_sound(settings["vrecog_activation_sound"])
self.stt.is_listening = True
if not self.stt.is_listening:
Expand Down

0 comments on commit e2dc09c

Please sign in to comment.