Fix
Browse files
main.py
CHANGED
|
@@ -1,8 +1,12 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from streamlit_webrtc import webrtc_streamer, get_hf_ice_servers, get_twilio_ice_servers, __version__ as st_webrtc_version
|
|
|
|
| 3 |
|
| 4 |
-
frontend_ice_type = st.selectbox("Frontend ICE type", ["Empty", "Google STUN", "Twilio TURN", "HF TURN only", "HF TURN and Google STUN", "None configured"])
|
| 5 |
-
backend_ice_type = st.selectbox("Backend ICE type", ["Empty", "Google STUN", "Twilio TURN", "HF TURN only", "HF TURN and Google STUN", "None configured"])
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
if frontend_ice_type == "Empty":
|
| 8 |
frontend_rtc_configuration = {
|
|
@@ -10,15 +14,22 @@ if frontend_ice_type == "Empty":
|
|
| 10 |
}
|
| 11 |
elif frontend_ice_type == "Google STUN":
|
| 12 |
frontend_rtc_configuration = {
|
| 13 |
-
"iceServers":
|
| 14 |
}
|
| 15 |
-
elif frontend_ice_type == "Twilio TURN":
|
| 16 |
frontend_rtc_configuration = {
|
| 17 |
"iceServers": get_twilio_ice_servers(
|
| 18 |
twilio_sid=st.secrets["TWILIO_ACCOUNT_SID"],
|
| 19 |
twilio_token=st.secrets["TWILIO_AUTH_TOKEN"],
|
| 20 |
)
|
| 21 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
elif frontend_ice_type == "HF TURN only":
|
| 23 |
hf_ice_servers = get_hf_ice_servers(token=st.secrets["HF_TOKEN"])
|
| 24 |
frontend_rtc_configuration = {
|
|
@@ -26,7 +37,7 @@ elif frontend_ice_type == "HF TURN only":
|
|
| 26 |
}
|
| 27 |
elif frontend_ice_type == "HF TURN and Google STUN":
|
| 28 |
hf_ice_servers = get_hf_ice_servers(token=st.secrets["HF_TOKEN"])
|
| 29 |
-
ice_servers = hf_ice_servers +
|
| 30 |
frontend_rtc_configuration = {
|
| 31 |
"iceServers": ice_servers
|
| 32 |
}
|
|
@@ -39,15 +50,22 @@ if backend_ice_type == "Empty":
|
|
| 39 |
}
|
| 40 |
elif backend_ice_type == "Google STUN":
|
| 41 |
backend_rtc_configuration = {
|
| 42 |
-
"iceServers":
|
| 43 |
}
|
| 44 |
-
elif backend_ice_type == "Twilio TURN":
|
| 45 |
backend_rtc_configuration = {
|
| 46 |
"iceServers": get_twilio_ice_servers(
|
| 47 |
twilio_sid=st.secrets["TWILIO_ACCOUNT_SID"],
|
| 48 |
twilio_token=st.secrets["TWILIO_AUTH_TOKEN"],
|
| 49 |
)
|
| 50 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
elif backend_ice_type == "HF TURN only":
|
| 52 |
hf_ice_servers = get_hf_ice_servers(token=st.secrets["HF_TOKEN"])
|
| 53 |
backend_rtc_configuration = {
|
|
@@ -55,7 +73,7 @@ elif backend_ice_type == "HF TURN only":
|
|
| 55 |
}
|
| 56 |
elif backend_ice_type == "HF TURN and Google STUN":
|
| 57 |
hf_ice_servers = get_hf_ice_servers(token=st.secrets["HF_TOKEN"])
|
| 58 |
-
ice_servers = hf_ice_servers +
|
| 59 |
backend_rtc_configuration = {
|
| 60 |
"iceServers": ice_servers
|
| 61 |
}
|
|
@@ -74,4 +92,5 @@ webrtc_streamer(
|
|
| 74 |
)
|
| 75 |
|
| 76 |
st.write(f"Streamlit version: {st.__version__}")
|
| 77 |
-
st.write(f"Streamlit-
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from streamlit_webrtc import webrtc_streamer, get_hf_ice_servers, get_twilio_ice_servers, __version__ as st_webrtc_version
|
| 3 |
+
import aiortc
|
| 4 |
|
| 5 |
+
frontend_ice_type = st.selectbox("Frontend ICE type", ["Empty", "Google STUN", "Twilio STUN/TURN", "Twilio STUN/TURN and Google STUN", "HF TURN only", "HF TURN and Google STUN", "None configured"])
|
| 6 |
+
backend_ice_type = st.selectbox("Backend ICE type", ["Empty", "Google STUN", "Twilio STUN/TURN", "Twilio STUN/TURN and Google STUN", "HF TURN only", "HF TURN and Google STUN", "None configured"])
|
| 7 |
+
|
| 8 |
+
# google_stun_ice_servers = [{"urls": ["stun:stun.l.google.com:19302"]}]
|
| 9 |
+
google_stun_ice_servers = [{"urls": "stun:stun.l.google.com:19302", "url": "stun:stun.l.google.com:19302"}]
|
| 10 |
|
| 11 |
if frontend_ice_type == "Empty":
|
| 12 |
frontend_rtc_configuration = {
|
|
|
|
| 14 |
}
|
| 15 |
elif frontend_ice_type == "Google STUN":
|
| 16 |
frontend_rtc_configuration = {
|
| 17 |
+
"iceServers": google_stun_ice_servers
|
| 18 |
}
|
| 19 |
+
elif frontend_ice_type == "Twilio STUN/TURN":
|
| 20 |
frontend_rtc_configuration = {
|
| 21 |
"iceServers": get_twilio_ice_servers(
|
| 22 |
twilio_sid=st.secrets["TWILIO_ACCOUNT_SID"],
|
| 23 |
twilio_token=st.secrets["TWILIO_AUTH_TOKEN"],
|
| 24 |
)
|
| 25 |
}
|
| 26 |
+
elif frontend_ice_type == "Twilio STUN/TURN and Google STUN":
|
| 27 |
+
frontend_rtc_configuration = {
|
| 28 |
+
"iceServers": google_stun_ice_servers + get_twilio_ice_servers(
|
| 29 |
+
twilio_sid=st.secrets["TWILIO_ACCOUNT_SID"],
|
| 30 |
+
twilio_token=st.secrets["TWILIO_AUTH_TOKEN"],
|
| 31 |
+
)
|
| 32 |
+
}
|
| 33 |
elif frontend_ice_type == "HF TURN only":
|
| 34 |
hf_ice_servers = get_hf_ice_servers(token=st.secrets["HF_TOKEN"])
|
| 35 |
frontend_rtc_configuration = {
|
|
|
|
| 37 |
}
|
| 38 |
elif frontend_ice_type == "HF TURN and Google STUN":
|
| 39 |
hf_ice_servers = get_hf_ice_servers(token=st.secrets["HF_TOKEN"])
|
| 40 |
+
ice_servers = hf_ice_servers + google_stun_ice_servers
|
| 41 |
frontend_rtc_configuration = {
|
| 42 |
"iceServers": ice_servers
|
| 43 |
}
|
|
|
|
| 50 |
}
|
| 51 |
elif backend_ice_type == "Google STUN":
|
| 52 |
backend_rtc_configuration = {
|
| 53 |
+
"iceServers": google_stun_ice_servers
|
| 54 |
}
|
| 55 |
+
elif backend_ice_type == "Twilio STUN/TURN":
|
| 56 |
backend_rtc_configuration = {
|
| 57 |
"iceServers": get_twilio_ice_servers(
|
| 58 |
twilio_sid=st.secrets["TWILIO_ACCOUNT_SID"],
|
| 59 |
twilio_token=st.secrets["TWILIO_AUTH_TOKEN"],
|
| 60 |
)
|
| 61 |
}
|
| 62 |
+
elif backend_ice_type == "Twilio STUN/TURN and Google STUN":
|
| 63 |
+
backend_rtc_configuration = {
|
| 64 |
+
"iceServers": google_stun_ice_servers + get_twilio_ice_servers(
|
| 65 |
+
twilio_sid=st.secrets["TWILIO_ACCOUNT_SID"],
|
| 66 |
+
twilio_token=st.secrets["TWILIO_AUTH_TOKEN"],
|
| 67 |
+
) + google_stun_ice_servers
|
| 68 |
+
}
|
| 69 |
elif backend_ice_type == "HF TURN only":
|
| 70 |
hf_ice_servers = get_hf_ice_servers(token=st.secrets["HF_TOKEN"])
|
| 71 |
backend_rtc_configuration = {
|
|
|
|
| 73 |
}
|
| 74 |
elif backend_ice_type == "HF TURN and Google STUN":
|
| 75 |
hf_ice_servers = get_hf_ice_servers(token=st.secrets["HF_TOKEN"])
|
| 76 |
+
ice_servers = hf_ice_servers + google_stun_ice_servers
|
| 77 |
backend_rtc_configuration = {
|
| 78 |
"iceServers": ice_servers
|
| 79 |
}
|
|
|
|
| 92 |
)
|
| 93 |
|
| 94 |
st.write(f"Streamlit version: {st.__version__}")
|
| 95 |
+
st.write(f"Streamlit-WebRTC version: {st_webrtc_version}")
|
| 96 |
+
st.write(f"aiortc version: {aiortc.__version__}")
|