Cloudflare turn integration (#264)

* Turn integration

* Add code:

* type hint

* Fix typehint

* add code

* format

* WIP

* trickle ice

* bump version

* Better docs

* Modify

* code

* Mute icon for whisper

* Add code

* llama 4 demo

* code

* OpenAI interruptions

* fix docs
This commit is contained in:
Freddy Boulton
2025-04-09 09:36:51 -04:00
committed by GitHub
parent f70b27bd41
commit 837330dcd8
37 changed files with 2914 additions and 780 deletions

View File

@@ -13,8 +13,8 @@ from fastrtc import (
AdditionalOutputs,
ReplyOnPause,
Stream,
get_cloudflare_turn_credentials_async,
get_stt_model,
get_twilio_turn_credentials,
)
from gradio.utils import get_space
from pydantic import BaseModel
@@ -75,7 +75,7 @@ stream = Stream(
additional_outputs=[chatbot, state],
additional_outputs_handler=lambda *a: (a[2], a[3]),
concurrency_limit=20 if get_space() else None,
rtc_configuration=get_twilio_turn_credentials() if get_space() else None,
rtc_configuration=get_cloudflare_turn_credentials_async,
)
app = FastAPI()
@@ -95,7 +95,9 @@ class InputData(BaseModel):
@app.get("/")
async def _():
rtc_config = get_twilio_turn_credentials() if get_space() else None
rtc_config = await get_cloudflare_turn_credentials_async(
hf_token=os.getenv("HF_TOKEN_ALT")
)
html_content = (curr_dir / "index.html").read_text()
html_content = html_content.replace("__RTC_CONFIGURATION__", json.dumps(rtc_config))
return HTMLResponse(content=html_content)