EngAbod commited on
Commit
83606e6
·
1 Parent(s): b0246ff

Update turn.py

Browse files
Files changed (1) hide show
  1. turn.py +7 -7
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
- # Ref: https://www.twilio.com/docs/stun-turn/api
21
  try:
22
- account_sid = os.environ["AC8620b566f7273df3b27724e1f1468afc"]
23
- auth_token = os.environ["631803725a8a5d737d1abf543d18e27c"]
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