Fix the object detection demo to use Twilio TURN server
Browse files- requirements.txt +1 -0
- sample_utils/turn.py +11 -12
requirements.txt
CHANGED
|
@@ -2,3 +2,4 @@ opencv-python-headless==4.7.0.72
|
|
| 2 |
pydub==0.25.1
|
| 3 |
streamlit==1.19.0
|
| 4 |
streamlit_webrtc==0.44.7
|
|
|
|
|
|
| 2 |
pydub==0.25.1
|
| 3 |
streamlit==1.19.0
|
| 4 |
streamlit_webrtc==0.44.7
|
| 5 |
+
twilio~=8.1.0
|
sample_utils/turn.py
CHANGED
|
@@ -1,26 +1,25 @@
|
|
| 1 |
import logging
|
| 2 |
import os
|
| 3 |
|
| 4 |
-
import
|
| 5 |
import streamlit as st
|
| 6 |
|
| 7 |
logger = logging.getLogger(__name__)
|
| 8 |
|
| 9 |
|
| 10 |
-
OPEN_RELAY_API_HOST = os.environ.get("OPEN_RELAY_API_HOST")
|
| 11 |
-
OPEN_RELAY_API_KEY = os.environ.get("OPEN_RELAY_API_KEY")
|
| 12 |
-
|
| 13 |
-
|
| 14 |
@st.cache_data
|
| 15 |
def get_ice_servers():
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
| 17 |
logger.warning(
|
| 18 |
-
"
|
| 19 |
)
|
| 20 |
return [{"urls": ["stun:stun.l.google.com:19302"]}]
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
return
|
|
|
|
| 1 |
import logging
|
| 2 |
import os
|
| 3 |
|
| 4 |
+
from twilio.rest import Client
|
| 5 |
import streamlit as st
|
| 6 |
|
| 7 |
logger = logging.getLogger(__name__)
|
| 8 |
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
@st.cache_data
|
| 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(
|
| 17 |
+
"Twilio credentials are not set. Fallback to a free STUN server from Google." # noqa: E501
|
| 18 |
)
|
| 19 |
return [{"urls": ["stun:stun.l.google.com:19302"]}]
|
| 20 |
|
| 21 |
+
client = Client(account_sid, auth_token)
|
| 22 |
+
|
| 23 |
+
token = client.tokens.create()
|
| 24 |
+
|
| 25 |
+
return token.ice_servers
|