SmallWebrtc

class pipecat.transports.network.small_webrtc.SmallWebRTCCallbacks(*, on_app_message, on_client_connected, on_client_disconnected)[source]

Bases: BaseModel

Parameters:
  • on_app_message (Callable[[Any], Awaitable[None]])

  • on_client_connected (Callable[[SmallWebRTCConnection], Awaitable[None]])

  • on_client_disconnected (Callable[[SmallWebRTCConnection], Awaitable[None]])

on_app_message: Callable[[Any], Awaitable[None]]
on_client_connected: Callable[[SmallWebRTCConnection], Awaitable[None]]
on_client_disconnected: Callable[[SmallWebRTCConnection], Awaitable[None]]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class pipecat.transports.network.small_webrtc.RawAudioTrack(*args, **kwargs)[source]

Bases: AudioStreamTrack

add_audio_bytes(audio_bytes)[source]

Adds bytes to the audio buffer and returns a Future that completes when the data is processed.

Parameters:

audio_bytes (bytes)

async recv()[source]

Returns the next audio frame, generating silence if needed.

class pipecat.transports.network.small_webrtc.RawVideoTrack(*args, **kwargs)[source]

Bases: VideoStreamTrack

add_video_frame(frame)[source]

Adds a raw video frame to the buffer.

async recv()[source]

Returns the next video frame, waiting if the buffer is empty.

class pipecat.transports.network.small_webrtc.SmallWebRTCClient(webrtc_connection, callbacks)[source]

Bases: object

Parameters:
  • webrtc_connection (SmallWebRTCConnection)

  • callbacks (SmallWebRTCCallbacks)

FORMAT_CONVERSIONS = {'gray': cv2.COLOR_GRAY2RGB, 'nv12': cv2.COLOR_YUV2RGB_NV12, 'yuv420p': cv2.COLOR_YUV2RGB_I420, 'yuvj420p': cv2.COLOR_YUV2RGB_I420}
async read_video_frame()[source]

Reads a video frame from the given MediaStreamTrack, converts it to RGB, and creates an InputImageRawFrame.

async read_audio_frame()[source]

Reads 20ms of audio from the given MediaStreamTrack and creates an InputAudioRawFrame.

async write_audio_frame(frame)[source]
Parameters:

frame (OutputAudioRawFrame)

async write_video_frame(frame)[source]
Parameters:

frame (OutputImageRawFrame)

async setup(_params, frame)[source]
Parameters:

_params (TransportParams)

async connect()[source]
async disconnect()[source]
async send_message(frame)[source]
Parameters:

frame (TransportMessageFrame | TransportMessageUrgentFrame)

property is_connected: bool
property is_closing: bool
class pipecat.transports.network.small_webrtc.SmallWebRTCInputTransport(client, params, **kwargs)[source]

Bases: BaseInputTransport

Parameters:
  • client (SmallWebRTCClient)

  • params (TransportParams)

async process_frame(frame, direction)[source]
Parameters:
  • frame (Frame)

  • direction (FrameDirection)

async start(frame)[source]
Parameters:

frame (StartFrame)

async stop(frame)[source]
Parameters:

frame (EndFrame)

async cancel(frame)[source]
Parameters:

frame (CancelFrame)

async push_app_message(message)[source]
Parameters:

message (Any)

async request_participant_image(frame)[source]

Requests an image frame from the participant’s video stream.

When a UserImageRequestFrame is received, this method will store the request and the next video frame received will be converted to a UserImageRawFrame.

Parameters:

frame (UserImageRequestFrame)

class pipecat.transports.network.small_webrtc.SmallWebRTCOutputTransport(client, params, **kwargs)[source]

Bases: BaseOutputTransport

Parameters:
  • client (SmallWebRTCClient)

  • params (TransportParams)

async start(frame)[source]
Parameters:

frame (StartFrame)

async stop(frame)[source]
Parameters:

frame (EndFrame)

async cancel(frame)[source]
Parameters:

frame (CancelFrame)

async send_message(frame)[source]
Parameters:

frame (TransportMessageFrame | TransportMessageUrgentFrame)

async write_audio_frame(frame)[source]
Parameters:

frame (OutputAudioRawFrame)

async write_video_frame(frame)[source]
Parameters:

frame (OutputImageRawFrame)

class pipecat.transports.network.small_webrtc.SmallWebRTCTransport(webrtc_connection, params, input_name=None, output_name=None)[source]

Bases: BaseTransport

Parameters:
  • webrtc_connection (SmallWebRTCConnection)

  • params (TransportParams)

  • input_name (str | None)

  • output_name (str | None)

input()[source]
Return type:

SmallWebRTCInputTransport

output()[source]
Return type:

SmallWebRTCOutputTransport

async send_image(frame)[source]
Parameters:

frame (OutputImageRawFrame | SpriteFrame)

async send_audio(frame)[source]
Parameters:

frame (OutputAudioRawFrame)