blasisd commited on
Commit
031e78b
·
1 Parent(s): 2a3432f

Changed turn credentials' retrieval

Browse files
Files changed (1) hide show
  1. src/app.py +11 -8
src/app.py CHANGED
@@ -23,12 +23,17 @@ from transformers import AutoProcessor, SeamlessM4Tv2Model
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,9 +203,7 @@ with gr.Blocks(
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
 
23
 
24
  load_dotenv(override=True)
25
 
 
 
26
 
27
+ async def get_turn_config():
28
+ try:
29
+ if get_space():
30
+ return await get_cloudflare_turn_credentials_async(
31
+ hf_token=os.getenv("HF_TOKEN")
32
+ )
33
+ return None
34
+ except Exception as e:
35
+ print(f"Failed to get TURN credentials: {e}")
36
+ return {"iceServers": [{"urls": ["stun:stun.l.google.com:19302"]}]}
37
 
38
 
39
  parent_dir = Path(__file__).parents[1]
 
203
  modality="audio",
204
  mode="send-receive",
205
  label="Audio Stream",
206
+ rtc_configuration=(get_turn_config if get_space() else None),
 
 
207
  # rtc_configuration=get_credentials,
208
  # server_rtc_configuration=get_cloudflare_turn_credentials(
209
  # ttl=360_000