Spaces:
Sleeping
Sleeping
Changed turn credentials' retrieval
Browse files- src/app.py +3 -21
src/app.py
CHANGED
@@ -12,7 +12,6 @@ import gradio as gr
|
|
12 |
|
13 |
from dotenv import load_dotenv
|
14 |
from fastrtc import (
|
15 |
-
Stream,
|
16 |
get_cloudflare_turn_credentials_async,
|
17 |
get_cloudflare_turn_credentials,
|
18 |
WebRTC,
|
@@ -25,18 +24,6 @@ from transformers import AutoProcessor, SeamlessM4Tv2Model
|
|
25 |
load_dotenv(override=True)
|
26 |
|
27 |
|
28 |
-
async def get_turn_config():
|
29 |
-
try:
|
30 |
-
if get_space():
|
31 |
-
return await get_cloudflare_turn_credentials_async(
|
32 |
-
hf_token=os.getenv("HF_TOKEN")
|
33 |
-
)
|
34 |
-
return None
|
35 |
-
except Exception as e:
|
36 |
-
print(f"Failed to get TURN credentials: {e}")
|
37 |
-
return {"iceServers": [{"urls": ["stun:stun.l.google.com:19302"]}]}
|
38 |
-
|
39 |
-
|
40 |
parent_dir = Path(__file__).parents[1]
|
41 |
config_path = Path(parent_dir, "configs")
|
42 |
|
@@ -199,19 +186,14 @@ with gr.Blocks(
|
|
199 |
elem_id="langDropdown",
|
200 |
)
|
201 |
|
202 |
-
print(get_cloudflare_turn_credentials(ttl=360_000))
|
203 |
-
|
204 |
with gr.Column(scale=5, elem_id="micCol"):
|
205 |
audio = WebRTC(
|
206 |
modality="audio",
|
207 |
mode="send-receive",
|
208 |
label="Audio Stream",
|
209 |
rtc_configuration=(
|
210 |
-
|
211 |
-
|
212 |
-
else None
|
213 |
-
), # (get_turn_config if get_space() else None),
|
214 |
-
# rtc_configuration=get_credentials,
|
215 |
# server_rtc_configuration=get_cloudflare_turn_credentials(
|
216 |
# ttl=360_000
|
217 |
# ),
|
@@ -222,7 +204,7 @@ with gr.Blocks(
|
|
222 |
ReplyOnPause(translate_audio),
|
223 |
inputs=[audio, target_lang],
|
224 |
outputs=[audio],
|
225 |
-
concurrency_limit=
|
226 |
)
|
227 |
|
228 |
# Sticky footer (will stay at bottom on all screen sizes)
|
|
|
12 |
|
13 |
from dotenv import load_dotenv
|
14 |
from fastrtc import (
|
|
|
15 |
get_cloudflare_turn_credentials_async,
|
16 |
get_cloudflare_turn_credentials,
|
17 |
WebRTC,
|
|
|
24 |
load_dotenv(override=True)
|
25 |
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
parent_dir = Path(__file__).parents[1]
|
28 |
config_path = Path(parent_dir, "configs")
|
29 |
|
|
|
186 |
elem_id="langDropdown",
|
187 |
)
|
188 |
|
|
|
|
|
189 |
with gr.Column(scale=5, elem_id="micCol"):
|
190 |
audio = WebRTC(
|
191 |
modality="audio",
|
192 |
mode="send-receive",
|
193 |
label="Audio Stream",
|
194 |
rtc_configuration=(
|
195 |
+
get_cloudflare_turn_credentials_async if get_space() else None
|
196 |
+
),
|
|
|
|
|
|
|
197 |
# server_rtc_configuration=get_cloudflare_turn_credentials(
|
198 |
# ttl=360_000
|
199 |
# ),
|
|
|
204 |
ReplyOnPause(translate_audio),
|
205 |
inputs=[audio, target_lang],
|
206 |
outputs=[audio],
|
207 |
+
concurrency_limit=20 if get_space() else None,
|
208 |
)
|
209 |
|
210 |
# Sticky footer (will stay at bottom on all screen sizes)
|