SS8297 commited on
Commit
4485e0a
·
1 Parent(s): 9b92a3d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -2
app.py CHANGED
@@ -1,10 +1,25 @@
1
  import streamlit as st
2
  from streamlit_webrtc import webrtc_streamer
3
  import av
 
 
4
 
5
- flip = st.checkbox("Flip")
 
 
 
 
 
 
 
 
 
 
6
 
 
7
 
 
 
8
  def video_frame_callback(frame):
9
  img = frame.to_ndarray(format="bgr24")
10
 
@@ -13,11 +28,13 @@ def video_frame_callback(frame):
13
  return av.VideoFrame.from_ndarray(flipped, format="bgr24")
14
 
15
 
 
 
16
  webrtc_streamer(
17
  key="example",
18
  video_frame_callback=video_frame_callback,
19
  rtc_configuration={ # Add this config
20
- "iceServers": [{"urls": ["stun:stun.l.google.com:19302"]}]
21
  }
22
  )
23
 
 
1
  import streamlit as st
2
  from streamlit_webrtc import webrtc_streamer
3
  import av
4
+ import os
5
+ from twilio.rest import Client
6
 
7
+ os.environ["TWILIO_ACCOUNT_SID"] = 223e5388402c66735407ff8d
8
+ os.environ["TWILIO_AUTH_TOKEN"] = eb4673a2020af7d412359956fd1a2e2de594
9
+
10
+
11
+ def get_ice_servers()
12
+ try:
13
+ account_sid = os.environ["TWILIO_ACCOUNT_SID"]
14
+ auth_token = os.environ["TWILIO_AUTH_TOKEN"]
15
+ except KeyError:
16
+ logger.warning("TURN credentials are not set. Fallback to a free STUN server from Google.")
17
+ return [{"urls": ["stun:stun.l.google.com:19302"]}]
18
 
19
+ client = Client(account_sid, auth_token)
20
 
21
+ token = client.tokens.create()
22
+
23
  def video_frame_callback(frame):
24
  img = frame.to_ndarray(format="bgr24")
25
 
 
28
  return av.VideoFrame.from_ndarray(flipped, format="bgr24")
29
 
30
 
31
+ flip = st.checkbox("Flip")
32
+
33
  webrtc_streamer(
34
  key="example",
35
  video_frame_callback=video_frame_callback,
36
  rtc_configuration={ # Add this config
37
+ "iceServers": get_ice_servers()
38
  }
39
  )
40