Overview
The pipecat-ai framework provides aCambTTSService that integrates Camb.ai’s MARS text-to-speech models into your voice AI pipelines. This integration enables high-quality, low-latency voice synthesis for real-time conversational AI applications.
Key Features
- MARS Models: Access to Camb.ai’s latest generation TTS models (mars-flash, mars-pro)
- 140+ Languages: Extensive multilingual support
- Real-time Streaming: Streaming audio chunks for low-latency output
- Model-specific Sample Rates: 22.05kHz (mars-flash) or 48kHz (mars-pro)
- Multiple Transports: Works with Daily, Twilio, WebRTC, and WebSocket transports
Installation
Prerequisites
- Python 3.9 or higher
- A Camb.ai API key (get one here)
- A transport provider account (e.g., Daily, Twilio)
Install Pipecat with Camb.ai Support
Quick Start
1. Set Up Environment Variables
Create a room at Daily Dashboard, then create a.env file in your project directory:
2. Create Your Voice Agent
3. Run Your Agent
Configuration
CambTTSService Options
TheCambTTSService class accepts the following parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | str | Required | Your Camb.ai API key |
voice_id | int | 147320 | Voice ID (browse voices at Camb.ai Studio) |
model | str | "mars-flash" | MARS model to use |
timeout | float | 60.0 | Request timeout in seconds |
sample_rate | int | Auto | Audio sample rate (auto-detected from model) |
params | InputParams | None | Additional voice parameters |
InputParams Options
| Parameter | Type | Default | Description |
|---|---|---|---|
language | Language | Language.EN | Language for synthesis |
Available Models
- Fast (Recommended)
- High Quality
Language Support
Camb.ai supports 140+ languages. Specify the language using Pipecat’sLanguage enum:
Advanced Usage
Dynamic Settings Updates
Update TTS settings during runtime:Using with Multiple Transports
Pipecat supports multiple transport backends. Here’s how to configure Camb.ai TTS with different transports:Metrics and Logging
Track usage and performance with Pipecat’s built-in metrics:Multi-Transport Voice Agent
Here’s a full example using the Pipecat runner utilities for transport-agnostic deployment:Tutorial: Local Voice Agent
Build a voice agent that runs on your local machine using your microphone and speakers - perfect for quick prototyping.Installation
Local Audio Example
Tutorial: Self-Hosted WebRTC Agent
Deploy a voice agent accessible from any browser without third-party services.Installation
WebRTC Server Example
Troubleshooting
Common Issues
Invalid API Key Error
Invalid API Key Error
Ensure your Or pass it directly:
CAMB_API_KEY environment variable is set correctly:Voice Not Found
Voice Not Found
The voice ID must be an integer. Browse available voices at Camb.ai Studio to find valid voice IDs.
Text Too Short Error
Text Too Short Error
Camb.ai requires a minimum of 3 characters for TTS synthesis. The service will log a warning and skip synthesis for shorter text.
Timeout Errors
Timeout Errors
TTS synthesis can take time for longer texts. The default timeout is 60 seconds. For very long texts, consider:
- Breaking them into smaller chunks
- Increasing the timeout:
CambTTSService(..., timeout=120.0)
Sample Rate Mismatch
Sample Rate Mismatch
Different models use different sample rates:
mars-flash: 22.05kHzmars-pro: 48kHz