Martlgap commited on
Commit
7d62c3d
·
1 Parent(s): 2c27175

testing twilio STUN

Browse files
Files changed (2) hide show
  1. requirements.txt +2 -1
  2. tools/webcam.py +43 -27
requirements.txt CHANGED
@@ -7,4 +7,5 @@ watchdog
7
  streamlit-webrtc
8
  matplotlib
9
  streamlit-toggle-switch
10
- tflite-runtime
 
 
7
  streamlit-webrtc
8
  matplotlib
9
  streamlit-toggle-switch
10
+ tflite-runtime
11
+ twilio
tools/webcam.py CHANGED
@@ -1,34 +1,50 @@
1
  import streamlit as st
2
  from streamlit_webrtc import webrtc_streamer, WebRtcMode, RTCConfiguration
 
 
 
 
3
 
 
 
 
 
 
4
 
5
- RTC_CONFIGURATION = RTCConfiguration({
6
- "iceServers": [
7
- {
8
- "urls": "stun:a.relay.metered.ca:80",
9
- },
10
- {
11
- "urls": "turn:a.relay.metered.ca:80",
12
- "username": "5b3af333bdecb76c15167cf2",
13
- "credential": "bGnptPEBRNPnMKLP",
14
- },
15
- {
16
- "urls": "turn:a.relay.metered.ca:80?transport=tcp",
17
- "username": "5b3af333bdecb76c15167cf2",
18
- "credential": "bGnptPEBRNPnMKLP",
19
- },
20
- {
21
- "urls": "turn:a.relay.metered.ca:443",
22
- "username": "5b3af333bdecb76c15167cf2",
23
- "credential": "bGnptPEBRNPnMKLP",
24
- },
25
- {
26
- "urls": "turn:a.relay.metered.ca:443?transport=tcp",
27
- "username": "5b3af333bdecb76c15167cf2",
28
- "credential": "bGnptPEBRNPnMKLP",
29
- },
30
- ],
31
- })
 
 
 
 
 
 
 
32
 
33
 
34
  @st.cache_resource(experimental_allow_widgets=True)
 
1
  import streamlit as st
2
  from streamlit_webrtc import webrtc_streamer, WebRtcMode, RTCConfiguration
3
+ ## This sample code is from https://www.twilio.com/docs/stun-turn/api
4
+ # Download the helper library from https://www.twilio.com/docs/python/install
5
+ import os
6
+ from twilio.rest import Client
7
 
8
+ # Find your Account SID and Auth Token at twilio.com/console
9
+ # and set the environment variables. See http://twil.io/secure
10
+ account_sid = os.environ['TWILIO_ACCOUNT_SID']
11
+ auth_token = os.environ['TWILIO_AUTH_TOKEN']
12
+ client = Client(account_sid, auth_token)
13
 
14
+ token = client.tokens.create()
15
+
16
+
17
+ RTC_CONFIGURATION={
18
+ "iceServers": token.ice_servers
19
+ }
20
+
21
+ # RTC_CONFIGURATION = RTCConfiguration({
22
+ # "iceServers": [
23
+ # {
24
+ # "urls": "stun:a.relay.metered.ca:80",
25
+ # },
26
+ # {
27
+ # "urls": "turn:a.relay.metered.ca:80",
28
+ # "username": "5b3af333bdecb76c15167cf2",
29
+ # "credential": "bGnptPEBRNPnMKLP",
30
+ # },
31
+ # {
32
+ # "urls": "turn:a.relay.metered.ca:80?transport=tcp",
33
+ # "username": "5b3af333bdecb76c15167cf2",
34
+ # "credential": "bGnptPEBRNPnMKLP",
35
+ # },
36
+ # {
37
+ # "urls": "turn:a.relay.metered.ca:443",
38
+ # "username": "5b3af333bdecb76c15167cf2",
39
+ # "credential": "bGnptPEBRNPnMKLP",
40
+ # },
41
+ # {
42
+ # "urls": "turn:a.relay.metered.ca:443?transport=tcp",
43
+ # "username": "5b3af333bdecb76c15167cf2",
44
+ # "credential": "bGnptPEBRNPnMKLP",
45
+ # },
46
+ # ],
47
+ # })
48
 
49
 
50
  @st.cache_resource(experimental_allow_widgets=True)