Testys commited on
Commit
ed2439c
·
verified ·
1 Parent(s): c863e7a

Update pages/1_Live_Detection.py

Browse files
Files changed (1) hide show
  1. pages/1_Live_Detection.py +27 -19
pages/1_Live_Detection.py CHANGED
@@ -93,25 +93,33 @@ class VideoProcessor(VideoProcessorBase):
93
  st.title("📹 Live Drowsiness Detection")
94
  st.info("Press 'START' to activate your camera and begin monitoring.")
95
 
96
- # --- Dynamically Build RTC Configuration ---
97
- @st.cache_data(ttl=3600) # Cache the credentials for 1 hour
98
- def get_ice_servers():
99
- """Build the list of ICE servers, including STUN and TURN from Metered."""
100
- if not secrets["metered_domain"] or not secrets["metered_api_key"]:
101
- print("No Metered credentials found. Using public STUN servers only.")
102
- return [{"urls": ["stun:stun.l.google.com:19302"]}]
103
-
104
- try:
105
- url = f"https://{secrets['metered_domain']}/api/v1/turn/credentials?apiKey={secrets['metered_api_key']}"
106
- response = requests.get(url)
107
- response.raise_for_status()
108
- print("Successfully fetched ICE servers from Metered.ca")
109
- return response.json()
110
- except requests.exceptions.RequestException as e:
111
- print(f"Warning: Could not fetch TURN credentials from Metered.ca: {e}")
112
- return [{"urls": ["stun:stun.l.google.com:19302"]}]
113
-
114
- RTC_CONFIGURATION = RTCConfiguration({"iceServers": get_ice_servers()})
 
 
 
 
 
 
 
 
115
 
116
  col1, col2 = st.columns([3, 1])
117
 
 
93
  st.title("📹 Live Drowsiness Detection")
94
  st.info("Press 'START' to activate your camera and begin monitoring.")
95
 
96
+ RTC_CONFIGURATION = RTCConfiguration({
97
+ "iceServers": [
98
+ {
99
+ "urls": ["stun:stun.relay.metered.ca:80"],
100
+ },
101
+ {
102
+ "urls": ["turn:global.relay.metered.ca:80"],
103
+ "username": "086986a440b20fe48229738b",
104
+ "credential": "mOC7fVSg00zjlsTD",
105
+ },
106
+ {
107
+ "urls": ["turn:global.relay.metered.ca:80?transport=tcp"],
108
+ "username": "086986a440b20fe48229738b",
109
+ "credential": "mOC7fVSg00zjlsTD",
110
+ },
111
+ {
112
+ "urls": ["turn:global.relay.metered.ca:443"],
113
+ "username": "086986a440b20fe48229738b",
114
+ "credential": "mOC7fVSg00zjlsTD",
115
+ },
116
+ {
117
+ "urls": ["turns:global.relay.metered.ca:443?transport=tcp"],
118
+ "username": "086986a440b20fe48229738b",
119
+ "credential": "mOC7fVSg00zjlsTD",
120
+ },
121
+ ]
122
+ })
123
 
124
  col1, col2 = st.columns([3, 1])
125