Community-maintained integration. This service is built and maintained by Kalpa Labs. Pipecat does not test or officially support it. Please report issues and request changes on the source repository. Learn more about community integrations.
Overview
KalpaTTSService converts text to speech through Kalpa’s streaming WebSocket API. KalpaHttpTTSService uses the HTTP streaming API. Kalpa Labs maintains both services inpipecat-kalpa.
For a walkthrough of TTS in a pipeline, see
Text-to-Speech.
Source Repository
Source code, runnable examples, changelog, and issues
Kalpa API Documentation
Current models, voices, and HTTP and WebSocket API behavior
Installation
Install the community package from its versioned Git release:Prerequisites
Create an API key in the Kalpa dashboard.Required Environment Variables
KALPA_API_KEY: Your Kalpa API key.
Configuration
KalpaTTSService
str
required
Kalpa API key. Raises
ValueError when empty.str
default:"wss://api.kalpalabs.ai"
WebSocket base URL for the Kalpa API.
TextAggregationMode
default:"TextAggregationMode.TOKEN"
How incoming text is aggregated before synthesis.
TOKEN forwards LLM text as
it arrives; SENTENCE aggregates sentences first. Import from
pipecat.services.tts_service.KalpaHttpTTSService
str
required
Kalpa API key. Raises
ValueError when empty.str
default:"https://api.kalpalabs.ai"
HTTP base URL for the Kalpa API.
aiohttp.ClientSession | None
default:"None"
Shared HTTP session. When
None, the service creates and closes its own
session. You are responsible for closing a session you provide.Settings
Pass settings throughKalpaTTSService.Settings(...) or
KalpaHttpTTSService.Settings(...). Both expose the following settings:
Use a
TTSUpdateSettingsFrame to
change settings during a conversation. Updating model or voice reconnects
the WebSocket service.
Usage
Add Kalpa to a Voice Pipeline
Place the service after your LLM and before the transport output. This example uses your existing transport, STT, LLM, and context aggregators:Use HTTP Synthesis
Use the HTTP service in the same pipeline position:Notes
- Audio format: Both services produce 24 kHz mono PCM audio. The output transport resamples it to the pipeline’s output rate.
- Interruptions: Use Pipecat’s
interruption handling to stop playback
when the user interrupts.
KalpaTTSServicecancels the interrupted response and reuses the connection for subsequent speech.
Event Handlers
KalpaTTSService supports the standard
service connection events:
Compatibility
Tested with Pipecat 1.13.0 on Python 3.12. Requires Python 3.11 or later and Pipecat 1.13.x (>=1.13.0,<1.14.0).