Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,20 @@ async def start( # type: ignore[override]
.to_jwt()
)

# Rebind audio output BEFORE the slow upstream HTTP call so
# subsequent generations are routed to the (about-to-arrive)
# avatar identity immediately. wait_remote_track buffers
# frames until the video track shows up, so nothing is lost
# in the gap.
agent_session.output.audio = DataStreamAudioOutput(
room=room,
destination_identity=self._avatar_participant_identity,
sample_rate=SAMPLE_RATE,
wait_remote_track=rtc.TrackKind.KIND_VIDEO,
clear_buffer_timeout=None,
wait_playback_start=True,
)

async with LemonSliceAPI(
api_url=self._api_url,
api_key=self._api_key,
Expand All @@ -115,13 +129,4 @@ async def start( # type: ignore[override]
extra_payload=self._extra_payload,
)

agent_session.output.audio = DataStreamAudioOutput(
room=room,
destination_identity=self._avatar_participant_identity,
sample_rate=SAMPLE_RATE,
wait_remote_track=rtc.TrackKind.KIND_VIDEO,
clear_buffer_timeout=None,
wait_playback_start=True,
)

return session_id
Loading