Skip to main content

Documentation Index

Fetch the complete documentation index at: https://lemonslice.com/docs/llms.txt

Use this file to discover all available pages before exploring further.

Overview

LemonSlice integrates with Pipecat, an open-source framework for building multimodal conversational agents by Daily. The LemonSliceTransport object connects your Pipecat app to a LemonSlice avatar for real-time voice conversations with synchronized video.
Jump to the example code section for ready-to-use samples.

Prerequisites

Before integrating LemonSlice with Pipecat, ensure you have the following:
  1. LemonSlice avatar configuration Either a base image URL or a LemonSlice avatar ID.
    • Agent base image — a publicly accessible image URL of your avatar, focused on the face. The image should be 368 × 560 pixels. LemonSlice will automatically center-crop your image to the target aspect ratio if the dimensions do not match the expected values. Best results are achieved with anthropomorphic images where the face and mouth are clearly identifiable.
    • LemonSlice Agent ID
      Selected voices and personalities for a LemonSlice avatar preset are ignored when using the Pipecat plugin.
  2. Pipecat Python Application

How to use

1

Install the plugin

Within your Pipecat app, install the LemonSlice transport:
SHELL
pip install "pipecat-ai[lemonslice]"
2

Authenticate

  1. Create a LemonSlice API key
  2. In your Pipecat app, set LEMONSLICE_API_KEY in your .env file
3

Create the LemonSlice transport layer

Create an instance of LemonSliceTransport by providing your bot name, LemonSlice API key, session request, and additional parameters.
PYTHON
import os
import aiohttp
from pipecat.transports.lemonslice.transport import (
    LemonSliceNewSessionRequest,
    LemonSliceParams,
    LemonSliceTransport,
)

async def main():
    async with aiohttp.ClientSession() as session:
        transport = LemonSliceTransport(
            bot_name="Pipecat",
            api_key=os.getenv("LEMONSLICE_API_KEY"),
            session=session,
            session_request=LemonSliceNewSessionRequest(
                agent_image_url="...",
            ),
        )

        # stt, tts, llm...
Parameters for LemonSliceTransport:
ParameterDescription
bot_nameThe name of the Pipecat bot instance.
api_keyLemonSlice API key for authentication.
sessionAn aiohttp.ClientSession for making async HTTP requests.
session_requestSession creation parameters. See LemonSliceNewSessionRequest below.
params(Optional) Transport configuration.
Parameters for LemonSliceNewSessionRequest.
ParameterDescription
agent_image_urlA URL to an avatar image to use. Provide either agent_id or agent_image_url, not both.
agent_idThe ID of a LemonSlice avatar preset. Provide either agent_id or agent_image_url, not both.
agent_prompt(Optional) A high-level system prompt that subtly influences the avatar’s movements, expressions, and emotional demeanor during the talking state.
agent_idle_prompt(Optional) A high-level system prompt that influences the avatar’s movements, expressions, and emotional demeanor during the idle state.
idle_timeout(Optional) Idle timeout in seconds. Defaults to 60. If a negative number is provided, the session will have no idle timeout.
response_done_timeout(Optional) Time in seconds to wait without receiving new audio bytes before marking the response as complete. Some TTS models do not send an end response event, or do not send it in a timely manner, after transmitting all audio bytes. This parameter enables detection of response completion when such events are missing or delayed.
daily_room_url(Optional) Daily room URL to use. If not provided, LemonSlice will create a new room at an additional cost of 0.51 credits per participant minute.
daily_token(Optional) Daily token for authenticating with the room.
lemonslice_properties(Optional) A dictionary of extra connection properties. See lemonslice_properties below.
Parameters for lemonslice_properties.
ParameterDescription
enable_recordingEnable Daily call recording. Must be one of cloud, cloud-audio-only, local, or raw-tracks. If set, recordings_bucket must also be provided. Enabling recording incurs an additional charge of 0.378 credits per minute.
recordings_bucketThe S3 bucket configuration where recordings will be saved. Follows the Daily recording bucket specification.
4

Insert the LemonSlice transport layer into the pipeline

Add the LemonSlice transport layer to your processing pipeline.
PYTHON
        # stt, tts, llm...

        pipeline = Pipeline(
            [
                transport.input(),
                stt,
                user_aggregator,
                llm,
                tts,
                transport.output(),
                assistant_aggregator,
            ]
        )

        task = PipelineTask(
            pipeline,
            params=PipelineParams(
                audio_in_sample_rate=16000,
                audio_out_sample_rate=16000,
            ),
        )
The LemonSlice avatar participant is automatically filtered out from transport.on_client_connected and transport.on_client_disconnected events. Only human participant connections trigger these event handlers.

Implementation Details

  • LemonSlice uses Daily as the underlying transport layer, so all Daily features and configuration options are available through the inherited DailyParams.
  • The transport automatically manages interruptions and sends appropriate control messages (interrupt, response_started, response_finished) to the LemonSlice session.
  • The LemonSlice avatar’s microphone is automatically muted to prevent audio feedback loops.
  • The Daily video UI should filter out the Pipecat bot participant from being displayed. This participant only exists to facilitate passing audio between the user, Pipecat, and LemonSlice.

Example Code

RepoWhat’s included
video-avatar-lemonslice-transport.pyRun a Pipecat pipeline locally and join with Daily Prebuilt to quickly test your agent with a LemonSlice avatar.
05-pipecat-appFullstack web app using the LemonSliceTransport within Pipecat. Includes LemonSlice-augmented Pipecat pipeline, front-end UI, and backend token server.

Additional resources

LemonSliceTransport documentation