whitphx's picture
whitphx HF Staff
Fix the object detection demo to use Twilio TURN server
5bebc6e
raw
history blame
606 Bytes
import logging
import os
from twilio.rest import Client
import streamlit as st
logger = logging.getLogger(__name__)
@st.cache_data
def get_ice_servers():
try:
account_sid = os.environ['TWILIO_ACCOUNT_SID']
auth_token = os.environ['TWILIO_AUTH_TOKEN']
except KeyError:
logger.warning(
"Twilio credentials are not set. Fallback to a free STUN server from Google." # noqa: E501
)
return [{"urls": ["stun:stun.l.google.com:19302"]}]
client = Client(account_sid, auth_token)
token = client.tokens.create()
return token.ice_servers