Spaces:
Sleeping
Sleeping
Added concurrency_limit and time_limit for stun
Browse files- src/app.py +11 -5
src/app.py
CHANGED
@@ -17,17 +17,18 @@ from fastrtc import (
|
|
17 |
WebRTC,
|
18 |
ReplyOnPause,
|
19 |
)
|
|
|
20 |
from transformers import AutoProcessor, SeamlessM4Tv2Model
|
21 |
|
22 |
|
23 |
load_dotenv(override=True)
|
24 |
|
25 |
-
# HF_TOKEN
|
26 |
-
HF_TOKEN = os.getenv("HF_TOKEN")
|
27 |
|
28 |
|
29 |
-
async def get_credentials():
|
30 |
-
|
31 |
|
32 |
|
33 |
parent_dir = Path(__file__).parents[1]
|
@@ -197,7 +198,10 @@ with gr.Blocks(
|
|
197 |
modality="audio",
|
198 |
mode="send-receive",
|
199 |
label="Audio Stream",
|
200 |
-
rtc_configuration=
|
|
|
|
|
|
|
201 |
# server_rtc_configuration=get_cloudflare_turn_credentials(
|
202 |
# ttl=360_000
|
203 |
# ),
|
@@ -208,6 +212,8 @@ with gr.Blocks(
|
|
208 |
ReplyOnPause(translate_audio),
|
209 |
inputs=[audio, target_lang],
|
210 |
outputs=[audio],
|
|
|
|
|
211 |
)
|
212 |
|
213 |
# Sticky footer (will stay at bottom on all screen sizes)
|
|
|
17 |
WebRTC,
|
18 |
ReplyOnPause,
|
19 |
)
|
20 |
+
from gradio.utils import get_space
|
21 |
from transformers import AutoProcessor, SeamlessM4Tv2Model
|
22 |
|
23 |
|
24 |
load_dotenv(override=True)
|
25 |
|
26 |
+
# # HF_TOKEN
|
27 |
+
# HF_TOKEN = os.getenv("HF_TOKEN")
|
28 |
|
29 |
|
30 |
+
# async def get_credentials():
|
31 |
+
# return await get_cloudflare_turn_credentials_async(hf_token=HF_TOKEN)
|
32 |
|
33 |
|
34 |
parent_dir = Path(__file__).parents[1]
|
|
|
198 |
modality="audio",
|
199 |
mode="send-receive",
|
200 |
label="Audio Stream",
|
201 |
+
rtc_configuration=(
|
202 |
+
get_cloudflare_turn_credentials_async if get_space() else None
|
203 |
+
),
|
204 |
+
# rtc_configuration=get_credentials,
|
205 |
# server_rtc_configuration=get_cloudflare_turn_credentials(
|
206 |
# ttl=360_000
|
207 |
# ),
|
|
|
212 |
ReplyOnPause(translate_audio),
|
213 |
inputs=[audio, target_lang],
|
214 |
outputs=[audio],
|
215 |
+
concurrency_limit=5 if get_space() else None,
|
216 |
+
time_limit=90 if get_space() else None,
|
217 |
)
|
218 |
|
219 |
# Sticky footer (will stay at bottom on all screen sizes)
|