Update app.py
Browse files
app.py
CHANGED
|
@@ -17,9 +17,15 @@ from fastapi import FastAPI, WebSocket, WebSocketDisconnect
|
|
| 17 |
from fastapi.responses import StreamingResponse
|
| 18 |
import uvicorn
|
| 19 |
from fastrtc import WebRTC, StreamHandler, get_cloudflare_turn_credentials
|
|
|
|
| 20 |
|
| 21 |
from reachy_mini.utils import create_head_pose
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
# -------------------------------------------------------------------
|
| 24 |
# 1. Configuration
|
| 25 |
# -------------------------------------------------------------------
|
|
@@ -42,8 +48,17 @@ TURN_TTL_SERVER_MS = 360_000
|
|
| 42 |
|
| 43 |
USE_VIDEO_WEBRTC = False
|
| 44 |
|
| 45 |
-
turn_credentials =
|
| 46 |
-
server_turn_credentials =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
|
| 49 |
# -------------------------------------------------------------------
|
|
@@ -191,7 +206,7 @@ class GlobalState:
|
|
| 191 |
body_yaw=p.body_yaw + dbody_yaw,
|
| 192 |
left_antenna=p.left_antenna,
|
| 193 |
right_antenna=p.right_antenna,
|
| 194 |
-
duration=0.
|
| 195 |
)
|
| 196 |
|
| 197 |
# Clamp posed values
|
|
@@ -1083,4 +1098,3 @@ if __name__ == "__main__":
|
|
| 1083 |
print("🚀 Server starting on http://0.0.0.0:7860")
|
| 1084 |
print("ℹ️ Point your Robot/Sim to: ws://<YOUR_PC_IP>:7860/robot")
|
| 1085 |
uvicorn.run(app, host="0.0.0.0", port=7860, proxy_headers=True, forwarded_allow_ips="*", log_level="warning")
|
| 1086 |
-
|
|
|
|
| 17 |
from fastapi.responses import StreamingResponse
|
| 18 |
import uvicorn
|
| 19 |
from fastrtc import WebRTC, StreamHandler, get_cloudflare_turn_credentials
|
| 20 |
+
from huggingface_hub import get_token
|
| 21 |
|
| 22 |
from reachy_mini.utils import create_head_pose
|
| 23 |
|
| 24 |
+
token = get_token()
|
| 25 |
+
|
| 26 |
+
if not token:
|
| 27 |
+
raise ValueError("No token found. Please set the HF_TOKEN environment variable or login to Hugging Face.")
|
| 28 |
+
|
| 29 |
# -------------------------------------------------------------------
|
| 30 |
# 1. Configuration
|
| 31 |
# -------------------------------------------------------------------
|
|
|
|
| 48 |
|
| 49 |
USE_VIDEO_WEBRTC = False
|
| 50 |
|
| 51 |
+
turn_credentials = None
|
| 52 |
+
server_turn_credentials = None
|
| 53 |
+
while turn_credentials is None or server_turn_credentials is None:
|
| 54 |
+
try:
|
| 55 |
+
if turn_credentials is None:
|
| 56 |
+
turn_credentials = get_cloudflare_turn_credentials(hf_token=token)
|
| 57 |
+
if server_turn_credentials is None:
|
| 58 |
+
server_turn_credentials = get_cloudflare_turn_credentials(ttl=TURN_TTL_SERVER_MS, hf_token=token)
|
| 59 |
+
except Exception as e:
|
| 60 |
+
print(f"[Video] Error getting turn credentials: {e!r}")
|
| 61 |
+
time.sleep(1)
|
| 62 |
|
| 63 |
|
| 64 |
# -------------------------------------------------------------------
|
|
|
|
| 206 |
body_yaw=p.body_yaw + dbody_yaw,
|
| 207 |
left_antenna=p.left_antenna,
|
| 208 |
right_antenna=p.right_antenna,
|
| 209 |
+
duration=0.1,
|
| 210 |
)
|
| 211 |
|
| 212 |
# Clamp posed values
|
|
|
|
| 1098 |
print("🚀 Server starting on http://0.0.0.0:7860")
|
| 1099 |
print("ℹ️ Point your Robot/Sim to: ws://<YOUR_PC_IP>:7860/robot")
|
| 1100 |
uvicorn.run(app, host="0.0.0.0", port=7860, proxy_headers=True, forwarded_allow_ips="*", log_level="warning")
|
|
|