mirror of
https://github.com/HumanAIGC-Engineering/gradio-webrtc.git
synced 2026-02-05 01:49:23 +08:00
24 lines
627 B
Markdown
24 lines
627 B
Markdown
When deploying in a cloud environment (like Hugging Face Spaces, EC2, etc), you need to set up a TURN server to relay the WebRTC traffic.
|
|
The easiest way to do this is to use a service like Twilio.
|
|
|
|
```python
|
|
from twilio.rest import Client
|
|
import os
|
|
|
|
account_sid = os.environ.get("TWILIO_ACCOUNT_SID")
|
|
auth_token = os.environ.get("TWILIO_AUTH_TOKEN")
|
|
|
|
client = Client(account_sid, auth_token)
|
|
|
|
token = client.tokens.create()
|
|
|
|
rtc_configuration = {
|
|
"iceServers": token.ice_servers,
|
|
"iceTransportPolicy": "relay",
|
|
}
|
|
|
|
with gr.Blocks() as demo:
|
|
...
|
|
rtc = WebRTC(rtc_configuration=rtc_configuration, ...)
|
|
...
|
|
``` |