Testys commited on
Commit
44f4448
Β·
verified Β·
1 Parent(s): b9d2bb7

Update src/alerting/alert_system.py

Browse files
Files changed (1) hide show
  1. src/alerting/alert_system.py +10 -6
src/alerting/alert_system.py CHANGED
@@ -25,19 +25,23 @@ class FileAlertSystem(BaseAlerter):
25
  super().__init__(config)
26
  self.audio_bytes = None
27
  try:
28
- p = config["alerting"]["alert_sound_path"]
29
- with open(p, "rb") as f:
30
  self.audio_bytes = f.read()
31
- print("Static alert sound loaded.")
32
  except Exception as e:
33
- print(f"Could not load alert sound: {e}")
34
 
35
  def trigger_alert(self, level="Very Drowsy"):
36
  now = time.time()
37
- if (now - self.last_alert_time) > self.cooldown and not self.alert_on and self.audio_bytes:
 
 
 
 
38
  self.last_alert_time = now
39
  self.alert_on = True
40
- return self.audio_bytes # return raw bytes
41
  return None
42
 
43
  # ──────────────────────────────────────────────────────────
 
25
  super().__init__(config)
26
  self.audio_bytes = None
27
  try:
28
+ path = config["alerting"]["alert_sound_path"]
29
+ with open(path, "rb") as f:
30
  self.audio_bytes = f.read()
31
+ print(f"[AlertSystem] loaded sound: {path}")
32
  except Exception as e:
33
+ print(f"[AlertSystem] could not load sound: {e}")
34
 
35
  def trigger_alert(self, level="Very Drowsy"):
36
  now = time.time()
37
+ if (
38
+ self.audio_bytes
39
+ and (now - self.last_alert_time) > self.cooldown
40
+ and not self.alert_on
41
+ ):
42
  self.last_alert_time = now
43
  self.alert_on = True
44
+ return self.audio_bytes
45
  return None
46
 
47
  # ──────────────────────────────────────────────────────────