Spaces:
Runtime error
Runtime error
Update turn.py
Browse files
turn.py
CHANGED
|
@@ -7,7 +7,6 @@ from twilio.rest import Client
|
|
| 7 |
|
| 8 |
logger = logging.getLogger(__name__)
|
| 9 |
|
| 10 |
-
|
| 11 |
@st.cache_data # type: ignore
|
| 12 |
def get_ice_servers():
|
| 13 |
"""Use Twilio's TURN server because Streamlit Community Cloud has changed
|
|
@@ -17,18 +16,19 @@ def get_ice_servers():
|
|
| 17 |
See https://github.com/whitphx/streamlit-webrtc/issues/1213
|
| 18 |
"""
|
| 19 |
|
| 20 |
-
#
|
| 21 |
try:
|
| 22 |
-
account_sid = os.environ["
|
| 23 |
-
auth_token = os.environ["
|
| 24 |
except KeyError:
|
| 25 |
logger.warning(
|
| 26 |
"Twilio credentials are not set. Fallback to a free STUN server from Google." # noqa: E501
|
| 27 |
)
|
| 28 |
-
return [{"urls": ["stun:stun.l.google.com:19302"]}
|
| 29 |
|
|
|
|
| 30 |
client = Client(account_sid, auth_token)
|
| 31 |
|
|
|
|
| 32 |
token = client.tokens.create()
|
| 33 |
-
|
| 34 |
-
return token.ice_servers
|
|
|
|
| 7 |
|
| 8 |
logger = logging.getLogger(__name__)
|
| 9 |
|
|
|
|
| 10 |
@st.cache_data # type: ignore
|
| 11 |
def get_ice_servers():
|
| 12 |
"""Use Twilio's TURN server because Streamlit Community Cloud has changed
|
|
|
|
| 16 |
See https://github.com/whitphx/streamlit-webrtc/issues/1213
|
| 17 |
"""
|
| 18 |
|
| 19 |
+
# Access Twilio credentials from environment variables
|
| 20 |
try:
|
| 21 |
+
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
|
| 22 |
+
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
|
| 23 |
except KeyError:
|
| 24 |
logger.warning(
|
| 25 |
"Twilio credentials are not set. Fallback to a free STUN server from Google." # noqa: E501
|
| 26 |
)
|
| 27 |
+
return [{"urls": ["stun:stun.l.google.com:19302"]}
|
| 28 |
|
| 29 |
+
# Create a Twilio client using the obtained credentials
|
| 30 |
client = Client(account_sid, auth_token)
|
| 31 |
|
| 32 |
+
# Generate a token and return the ICE servers
|
| 33 |
token = client.tokens.create()
|
| 34 |
+
return token.ice_servers
|
|
|