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:
| Service | Transport | Use it for |
|---|---|---|
KalpaTTSService | WebSocket | Most voice agents. Streams the LLM's reply over one connection as it is written, so speech starts before the reply is finished. |
KalpaHttpTTSService | HTTP streaming | One 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:
uv add pipecat-kalpa
# or
pip install pipecat-kalpaCreate an API key at kalpalabs.ai/dashboard/keys and export it where your agent runs:
export KALPA_API_KEY=...Add Kalpa to a pipeline
Place the service after the LLM and before the transport output:
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_ in the same position.
Voice and model
Pass settings to pick a voice and model:
tts = KalpaTTSService(
api_key=os.environ["KALPA_API_KEY"],
settings=KalpaTTSService.Settings(
voice="dda5319f-3b81-4124-b69e-9241eb510b77", # Wren
model="kalpa-tts-1",
),
)| Setting | Default | Notes |
|---|---|---|
voice | 18c26f49- (Arjun) | A voice id from GET /v1/voices — see Named voices. |
model | kalpa-tts-1 | A model id from GET /v1/models — see Models. |
language | None | Guides Pipecat's sentence splitting; it is not sent to Kalpa. |
KalpaHttpTTSService. 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.): the default TextAggregationMode. 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:
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 webrtcOpen 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
- kalpalabs/pipecat-kalpa: source, changelog, issues, and the README that tracks the current release and Pipecat compatibility.
- pipecat-kalpa on PyPI: released versions.
- Kalpa on docs.pipecat.ai: Pipecat's reference page for both services.