client_transport
The harness’s WebSocket transport and recorder.
A live transport carries continuous audio both ways, speech or silence, and VADs, turn detection, and streaming STT rely on that cadence. The eval bot sends and receives audio only while a TTS produces it, so both edges here reshape it: the output paces the user’s audio to the bot one 40 ms frame per tick, silence in between, and the input re-emits the bot’s audio at the same cadence, filling its gaps, so the harness’s VAD finds the bot’s real turn ends.
The recording does not use the paced streams, whose jitter would make it
stutter: EvalClientRecorder is fed the raw audio on both edges and
lays each side out on its own timeline.
- class pipecat.evals.client_transport.EvalClientRecorder(sample_rate: int)[source]
Bases:
objectBuilds the conversation recording from the raw audio, not the paced streams.
Python cannot hold the 40 ms pacing tick precisely, and a recording of the paced streams stutters. So each side is recorded as it was produced or received, laid out on its own timeline with silence only where a real pause was, and mixed to mono at
write(). Audio the bot sent past an interruption is dropped, as a real client would drop it.- GAP_S = 0.2
- __init__(sample_rate: int)[source]
Initialize the recorder.
- Parameters:
sample_rate – Output sample rate; both sides are resampled to it on write.
- add_user(audio: bytes, in_rate: int) None[source]
Record a chunk of the user’s TTS audio (raw, before pacing to the bot).
- add_bot(audio: bytes, in_rate: int) None[source]
Record a chunk of the bot’s audio (raw, before the gap-fill loop).
- drop_bot_tail(num_bytes: int) None[source]
Drop the last
num_bytesof the bot’s audio: sent, but never played.
- class pipecat.evals.client_transport.EvalClientOutputTransport(*args, recorder: EvalClientRecorder | None = None, **kwargs)[source]
Bases:
WebsocketClientOutputTransportStreams the user’s audio to the bot as a continuous real-time stream.
A real-time task sends one 40 ms frame per tick: queued TTS audio when there is some, silence otherwise, so the bot’s VAD and turn detection see the silence they need to end a turn. Runs only when audio output is on.
- __init__(*args, recorder: EvalClientRecorder | None = None, **kwargs)[source]
Initialize the transport and its (lazily started) send stream.
- async start(frame: StartFrame)[source]
Start the transport and, in audio mode, the real-time send stream.
- async cancel(frame: CancelFrame)[source]
Cancel the send stream, then the transport.
- async process_frame(frame: Frame, direction: FrameDirection)[source]
Pass a frame on; an interruption drops the user audio not yet sent, and the recorder drops the same bytes.
- async write_audio_frame(frame: OutputAudioRawFrame) bool[source]
Queue the user audio for the send task.
Returns False so the media sender does not push this un-paced frame downstream; the send task pushes the paced frames instead.
- class pipecat.evals.client_transport.EvalClientInputTransport(*args, recorder: EvalClientRecorder | None = None, **kwargs)[source]
Bases:
WebsocketClientInputTransportFeeds the bot’s audio to the harness’s VAD and STT as a continuous stream.
The bot sends audio only while its TTS produces it, with gaps at its pauses. A gap reads as silence to a VAD, which would end the bot’s turn mid-sentence, so the audio is buffered and re-emitted one 40 ms frame per tick, silence filling the gaps.
- __init__(*args, recorder: EvalClientRecorder | None = None, **kwargs)[source]
Initialize the transport and its (lazily started) fill stream.
- async start(frame: StartFrame)[source]
Start the transport and, when audio is enabled, the gap-fill stream.
- async cancel(frame: CancelFrame)[source]
Cancel the fill stream, then the transport.
- async push_frame(frame: Frame, direction: FrameDirection = FrameDirection.DOWNSTREAM)[source]
Push a frame on; when the bot reports an interruption, the audio it sent but a client would never play is dropped, and the recorder drops the same bytes.
- async push_audio_frame(frame: InputAudioRawFrame)[source]
Buffer the bot’s audio for the fill task.
- class pipecat.evals.client_transport.EvalClientTransport(*args, flags: EvalConnectionFlags | None = None, recorder: EvalClientRecorder | None = None, **kwargs)[source]
Bases:
RTVIClientTransportThe harness’s RTVI client transport, with audio edges that behave like a live transport.
The input fills the gaps in the bot’s audio and the output paces the user’s; both feed the recorder the raw audio when one is given. On connect it sends the connection’s flags in an
eval-connectmessage, ahead of the RTVI handshake.- __init__(*args, flags: EvalConnectionFlags | None = None, recorder: EvalClientRecorder | None = None, **kwargs)[source]
Initialize the transport, optionally wiring a recorder to both edges.
- Parameters:
flags – The connection’s flags, sent first on connect;
Nonesends the defaults.recorder – Optional
EvalClientRecorderfed the raw audio on both edges;Nonedisables recording.*args – Forwarded to
RTVIClientTransport.**kwargs – Forwarded to the parent transport.
- input() WebsocketClientInputTransport[source]
Return the gap-filling input transport.
- output() WebsocketClientOutputTransport[source]
Return the stream-shaping output transport.