Kalpa LabsDocs
DashboardGet API key
Integrations

Pipecat

Speak Pipecat agent replies in Kalpa voices with the pipecat-kalpa services, over WebSocket or HTTP streaming.

Pipecat is an open-source Python framework for real-time voice and multimodal agents. The pipecat-kalpa community package, maintained by Kalpa Labs, adds two Kalpa text-to-speech services to it, and Pipecat's docs list it as a community integration alongside its TTS services:

ServiceTransportUse it for
KalpaTTSServiceWebSocketMost voice agents. Streams the LLM's reply over one connection as it is written, so speech starts before the reply is finished.
KalpaHttpTTSServiceHTTP streamingOne streaming HTTP request per sentence, with no connection held open.

Install

The package needs Python 3.11 or later and Pipecat 1.13.x. Install it from PyPI:

Shell
uv add pipecat-kalpa
# or
pip install pipecat-kalpa

Create an API key at kalpalabs.ai/dashboard/keys and export it where your agent runs:

Shell
export KALPA_API_KEY=...

Add Kalpa to a pipeline

Place the service after the LLM and before the transport output:

Python
import os

from pipecat.pipeline.pipeline import Pipeline
from pipecat_kalpa import KalpaTTSService

tts = KalpaTTSService(api_key=os.environ["KALPA_API_KEY"])

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

transport, stt, llm and the context aggregators are the rest of your application. For HTTP streaming, put KalpaHttpTTSService(api_key=os.environ["KALPA_API_KEY"]) in the same position.

Voice and model

Pass settings to pick a voice and model:

Python
tts = KalpaTTSService(
    api_key=os.environ["KALPA_API_KEY"],
    settings=KalpaTTSService.Settings(
        voice="dda5319f-3b81-4124-b69e-9241eb510b77",  # Wren
        model="kalpa-tts-1",
    ),
)
SettingDefaultNotes
voice18c26f49-9f9c-400c-bec9-7467f28e1db5 (Arjun)A voice id from GET /v1/voices — see Named voices.
modelkalpa-tts-1A model id from GET /v1/models — see Models.
languageNoneGuides Pipecat's sentence splitting; it is not sent to Kalpa.

KalpaHttpTTSService.Settings takes the same settings. To change the voice or model mid-session, push a TTSUpdateSettingsFrame; the WebSocket service reconnects to apply it.

The constructors also take base_url (default wss://api.kalpalabs.ai for the WebSocket service, https://api.kalpalabs.ai for HTTP). KalpaTTSService takes text_aggregation_mode (TextAggregationMode is in pipecat.services.tts_service): the default TextAggregationMode.TOKEN forwards LLM text as it arrives, and SENTENCE collects whole sentences first. KalpaHttpTTSService takes an optional aiohttp_session to share.

Audio and interruptions

Both services produce 24 kHz mono 16-bit PCM. Pipecat's output transport resamples it to your pipeline's output rate, so neither service takes a sample_rate.

When the user interrupts, Pipecat stops playback and KalpaTTSService cancels the reply still being generated, then keeps the same connection for the next one.

Run the example agent

The package ships a voice agent that uses Deepgram for speech recognition, OpenAI for replies and Kalpa for speech, and talks to your browser over WebRTC:

Shell
git clone https://github.com/kalpalabs/pipecat-kalpa.git
cd pipecat-kalpa
uv sync --extra examples
cp .env.example .env   # set KALPA_API_KEY, DEEPGRAM_API_KEY and OPENAI_API_KEY
uv run --extra examples python examples/voice.py --transport webrtc

Open the address it prints, allow microphone access and connect. Talk over the assistant to interrupt it. Set KALPA_TTS_TRANSPORT=http to run the same agent with KalpaHttpTTSService, and KALPA_VOICE_ID to pick its voice.

Resources