feat: add coturn for remote deployments (#84)

* feat: add coturn for remote deployment

* Simplify remote setup

* fix logic in UI
This commit is contained in:
Abhishek 2025-12-22 13:29:41 +05:30 committed by GitHub
parent 2e37c89310
commit 17409998d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 326 additions and 144 deletions

View file

@ -20,7 +20,7 @@ RUN pip install --user --no-cache-dir -r requirements.txt && \
# Copy and install pipecat from local submodule
COPY pipecat /tmp/pipecat
RUN pip install --user --no-cache-dir '/tmp/pipecat[cartesia,deepgram,openai,elevenlabs,groq,google,azure,soundfile,silero,webrtc]' && \
RUN pip install --user --no-cache-dir '/tmp/pipecat[cartesia,deepgram,openai,elevenlabs,groq,google,azure,soundfile,silero,webrtc,local-smart-turn-v3]' && \
# Clean up pip cache and temporary pipecat directory
rm -rf /root/.cache/pip /tmp/pipecat

View file

@ -10,9 +10,11 @@ Uses the SmallWebRTC API contract:
"""
import asyncio
import os
from datetime import UTC, datetime
from typing import Dict
from typing import Dict, List
from aiortc import RTCIceServer
from aiortc.sdp import candidate_from_sdp
from fastapi import APIRouter, Depends, WebSocket, WebSocketDisconnect
from loguru import logger
@ -28,8 +30,34 @@ from pipecat.utils.context import set_current_run_id
router = APIRouter(prefix="/ws")
def get_ice_servers() -> List[RTCIceServer]:
"""Build ICE servers configuration including TURN if configured."""
servers: List[RTCIceServer] = [RTCIceServer(urls="stun:stun.l.google.com:19302")]
# Add TURN server if configured
turn_host = os.getenv("TURN_HOST")
turn_username = os.getenv("TURN_USERNAME")
turn_password = os.getenv("TURN_PASSWORD")
if turn_host and turn_username and turn_password:
servers.append(
RTCIceServer(
urls=[
f"turn:{turn_host}:3478",
f"turn:{turn_host}:3478?transport=tcp",
],
username=turn_username,
credential=turn_password,
)
)
logger.info(f"TURN server configured: {turn_host}:3478")
return servers
# ICE servers configuration
ice_servers = ["stun:stun.l.google.com:19302"]
ice_servers = get_ice_servers()
class SignalingManager: