Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -15,7 +15,6 @@ import time
|
|
15 |
# from streamer import ParlerTTSStreamer # local file
|
16 |
|
17 |
from src.detection.factory import get_detector
|
18 |
-
from src.alerting.alert_system import FileAlertSystem
|
19 |
|
20 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
21 |
# CONFIG & BACKEND SET-UP
|
@@ -32,13 +31,18 @@ logging.basicConfig(
|
|
32 |
with open("config.yaml", "r") as f:
|
33 |
config = yaml.safe_load(f)
|
34 |
|
35 |
-
|
36 |
|
37 |
print("Initializing detector and alerter β¦")
|
38 |
detector = get_detector(config)
|
39 |
-
alerter = FileAlertSystem(config)
|
40 |
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
logging.warning("No alert sound loaded; driver will not hear any audio!")
|
43 |
|
44 |
print("Backend ready.")
|
@@ -66,10 +70,8 @@ def process_live_frame(frame):
|
|
66 |
if lighting == "Low"
|
67 |
else f"Status: {level}\nScore: {score:.2f}")
|
68 |
|
69 |
-
audio_out = None
|
70 |
-
audio_out = None
|
71 |
if level != "Awake" and lighting != "Low":
|
72 |
-
audio_bytes =
|
73 |
logging.info(f"Printing {audio_bytes}")
|
74 |
if audio_bytes:
|
75 |
audio_out = audio_bytes
|
|
|
15 |
# from streamer import ParlerTTSStreamer # local file
|
16 |
|
17 |
from src.detection.factory import get_detector
|
|
|
18 |
|
19 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
20 |
# CONFIG & BACKEND SET-UP
|
|
|
31 |
with open("config.yaml", "r") as f:
|
32 |
config = yaml.safe_load(f)
|
33 |
|
34 |
+
|
35 |
|
36 |
print("Initializing detector and alerter β¦")
|
37 |
detector = get_detector(config)
|
|
|
38 |
|
39 |
+
path = config["alerting"]["alert_sound_path"]
|
40 |
+
with open(path, "rb") as f:
|
41 |
+
audio_bytes = f.read()
|
42 |
+
print(f"[AlertSystem] loaded sound: {audio_bytes}")
|
43 |
+
|
44 |
+
|
45 |
+
if audio_bytes is None:
|
46 |
logging.warning("No alert sound loaded; driver will not hear any audio!")
|
47 |
|
48 |
print("Backend ready.")
|
|
|
70 |
if lighting == "Low"
|
71 |
else f"Status: {level}\nScore: {score:.2f}")
|
72 |
|
|
|
|
|
73 |
if level != "Awake" and lighting != "Low":
|
74 |
+
audio_bytes = audio_bytes
|
75 |
logging.info(f"Printing {audio_bytes}")
|
76 |
if audio_bytes:
|
77 |
audio_out = audio_bytes
|