Commit ·
b3e81ab
1
Parent(s): bd28f17
we keep making svelte angry
Browse files- fastrtc_magenta.py +10 -24
fastrtc_magenta.py
CHANGED
|
@@ -344,34 +344,20 @@ def create_magenta_stream(
|
|
| 344 |
if not FASTRTC_AVAILABLE:
|
| 345 |
raise ImportError("FastRTC not installed. Run: pip install fastrtc")
|
| 346 |
|
| 347 |
-
#
|
| 348 |
hf_token = os.getenv("HF_TOKEN")
|
| 349 |
print(f"[FastRTC] HF_TOKEN present: {bool(hf_token)}, length: {len(hf_token) if hf_token else 0}")
|
| 350 |
|
| 351 |
-
|
| 352 |
-
server_creds = None
|
| 353 |
try:
|
| 354 |
-
|
| 355 |
-
print(f"[FastRTC]
|
| 356 |
-
print(f"[FastRTC] server_creds: {server_creds}")
|
| 357 |
except Exception as e:
|
| 358 |
-
print(f"[FastRTC] ERROR getting
|
| 359 |
import traceback
|
| 360 |
traceback.print_exc()
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
async def get_rtc_config():
|
| 364 |
-
try:
|
| 365 |
-
creds = await get_cloudflare_turn_credentials_async(hf_token=hf_token)
|
| 366 |
-
print(f"[FastRTC] async creds type: {type(creds)}")
|
| 367 |
-
print(f"[FastRTC] async creds: {creds}")
|
| 368 |
-
return creds
|
| 369 |
-
except Exception as e:
|
| 370 |
-
print(f"[FastRTC] ERROR in async get_rtc_config: {e}")
|
| 371 |
-
import traceback
|
| 372 |
-
traceback.print_exc()
|
| 373 |
-
# Fallback to STUN only (will likely fail but won't break the app)
|
| 374 |
-
return {"iceServers": [{"urls": "stun:stun.l.google.com:19302"}]}
|
| 375 |
|
| 376 |
handler = MagentaRTStreamHandler(
|
| 377 |
get_mrt_fn=get_mrt_fn,
|
|
@@ -385,8 +371,8 @@ def create_magenta_stream(
|
|
| 385 |
mode="receive",
|
| 386 |
concurrency_limit=concurrency_limit,
|
| 387 |
time_limit=time_limit,
|
| 388 |
-
rtc_configuration=
|
| 389 |
-
server_rtc_configuration=
|
| 390 |
additional_inputs=[
|
| 391 |
gr.Slider(0.1, 2.0, step=0.01, value=1.1, label="Temperature"),
|
| 392 |
gr.Slider(0.0, 8.0, step=0.1, value=1.1, label="Guidance Weight"),
|
|
@@ -399,4 +385,4 @@ def create_magenta_stream(
|
|
| 399 |
],
|
| 400 |
)
|
| 401 |
|
| 402 |
-
return stream
|
|
|
|
| 344 |
if not FASTRTC_AVAILABLE:
|
| 345 |
raise ImportError("FastRTC not installed. Run: pip install fastrtc")
|
| 346 |
|
| 347 |
+
# Get credentials synchronously
|
| 348 |
hf_token = os.getenv("HF_TOKEN")
|
| 349 |
print(f"[FastRTC] HF_TOKEN present: {bool(hf_token)}, length: {len(hf_token) if hf_token else 0}")
|
| 350 |
|
| 351 |
+
rtc_creds = None
|
|
|
|
| 352 |
try:
|
| 353 |
+
rtc_creds = get_cloudflare_turn_credentials(hf_token=hf_token, ttl=360_000)
|
| 354 |
+
print(f"[FastRTC] rtc_creds: {rtc_creds}")
|
|
|
|
| 355 |
except Exception as e:
|
| 356 |
+
print(f"[FastRTC] ERROR getting credentials: {e}")
|
| 357 |
import traceback
|
| 358 |
traceback.print_exc()
|
| 359 |
+
# Fallback
|
| 360 |
+
rtc_creds = {"iceServers": [{"urls": "stun:stun.l.google.com:19302"}]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 361 |
|
| 362 |
handler = MagentaRTStreamHandler(
|
| 363 |
get_mrt_fn=get_mrt_fn,
|
|
|
|
| 371 |
mode="receive",
|
| 372 |
concurrency_limit=concurrency_limit,
|
| 373 |
time_limit=time_limit,
|
| 374 |
+
rtc_configuration=rtc_creds, # Static dict, not async callable
|
| 375 |
+
server_rtc_configuration=rtc_creds, # Same creds for both
|
| 376 |
additional_inputs=[
|
| 377 |
gr.Slider(0.1, 2.0, step=0.01, value=1.1, label="Temperature"),
|
| 378 |
gr.Slider(0.0, 8.0, step=0.1, value=1.1, label="Guidance Weight"),
|
|
|
|
| 385 |
],
|
| 386 |
)
|
| 387 |
|
| 388 |
+
return stream
|