2026-04-29 11:39:57 +05:30
|
|
|
"""Transport factories for non-telephony pipelines.
|
2025-09-09 14:37:32 +05:30
|
|
|
|
2026-04-29 11:39:57 +05:30
|
|
|
Telephony transports live in their respective ``api.services.telephony.providers/<name>/transport.py``.
|
2026-05-16 17:45:12 +05:30
|
|
|
This module hosts only the shared, non-telephony transports (WebRTC).
|
2026-04-29 11:39:57 +05:30
|
|
|
"""
|
2025-09-09 14:37:32 +05:30
|
|
|
|
|
|
|
|
from api.services.pipecat.audio_config import AudioConfig
|
2026-04-29 11:39:57 +05:30
|
|
|
from api.services.pipecat.audio_mixer import build_audio_out_mixer
|
2026-05-16 18:05:23 +05:30
|
|
|
from api.services.pipecat.transport_params import realtime_param_overrides
|
2025-09-09 14:37:32 +05:30
|
|
|
from pipecat.transports.base_transport import TransportParams
|
2025-09-20 14:07:00 +05:30
|
|
|
from pipecat.transports.smallwebrtc.connection import SmallWebRTCConnection
|
|
|
|
|
from pipecat.transports.smallwebrtc.transport import SmallWebRTCTransport
|
2025-11-28 09:36:04 +05:30
|
|
|
|
|
|
|
|
|
2026-04-09 13:49:20 +05:30
|
|
|
async def create_webrtc_transport(
|
2025-09-09 14:37:32 +05:30
|
|
|
webrtc_connection: SmallWebRTCConnection,
|
|
|
|
|
workflow_run_id: int,
|
|
|
|
|
audio_config: AudioConfig,
|
|
|
|
|
ambient_noise_config: dict | None = None,
|
2026-05-16 18:05:23 +05:30
|
|
|
is_realtime: bool = False,
|
2025-09-09 14:37:32 +05:30
|
|
|
):
|
2026-04-29 11:39:57 +05:30
|
|
|
"""Create a transport for WebRTC connections."""
|
|
|
|
|
mixer = await build_audio_out_mixer(
|
2026-04-09 13:49:20 +05:30
|
|
|
audio_config.transport_out_sample_rate, ambient_noise_config
|
|
|
|
|
)
|
|
|
|
|
|
2025-09-09 14:37:32 +05:30
|
|
|
return SmallWebRTCTransport(
|
|
|
|
|
webrtc_connection=webrtc_connection,
|
|
|
|
|
params=TransportParams(
|
|
|
|
|
audio_in_enabled=True,
|
|
|
|
|
audio_out_enabled=True,
|
|
|
|
|
audio_in_sample_rate=audio_config.transport_in_sample_rate,
|
|
|
|
|
audio_out_sample_rate=audio_config.transport_out_sample_rate,
|
2026-04-09 13:49:20 +05:30
|
|
|
audio_out_mixer=mixer,
|
2026-05-16 18:05:23 +05:30
|
|
|
**realtime_param_overrides(is_realtime),
|
2025-09-09 14:37:32 +05:30
|
|
|
),
|
|
|
|
|
)
|