Overview
DeepgramTTSService provides high-quality text-to-speech synthesis using Deepgram’s Aura API with streaming capabilities and ultra-low latency. The service offers various voice models optimized for conversational AI applications with efficient audio streaming.
Deepgram TTS API Reference
Pipecat’s API methods for Deepgram TTS integration
Example Implementation
Complete example with Silero VAD
Deepgram Documentation
Official Deepgram Aura TTS API documentation
Voice Models
Browse available Aura voice models
Installation
To use Deepgram services, install the required dependencies:Prerequisites
Deepgram Account Setup
Before using Deepgram TTS services, you need:- Deepgram Account: Sign up at Deepgram Console
- API Key: Generate an API key from your project dashboard
- Voice Selection: Choose from available Aura voice models
Required Environment Variables
DEEPGRAM_API_KEY: Your Deepgram API key for authentication
Configuration
DeepgramTTSService
Deepgram API key for authentication.
Voice model to use for synthesis.
WebSocket base URL for Deepgram API.
Output audio sample rate in Hz. When
None, uses the pipeline’s configured sample rate.Audio encoding format. Must be one of:
"linear16", "mulaw", "alaw".DeepgramHttpTTSService
Deepgram API key for authentication.
Voice model to use for synthesis.
An aiohttp session for HTTP requests. You must create and manage this yourself.
HTTP API base URL.
Output audio sample rate in Hz.
Audio encoding format.
Usage
Basic Setup
HTTP Service
Notes
- WebSocket vs HTTP: The WebSocket service (
DeepgramTTSService) supports real-time streaming with interruption handling via the Clear message, making it suitable for interactive conversations. The HTTP service is simpler but processes each request as a batch. - Flush behavior: The WebSocket service automatically flushes pending text when it receives an
LLMFullResponseEndFrameorEndFrame, forcing Deepgram to generate audio for any remaining buffered text. - Encoding validation: The WebSocket service validates the
encodingparameter at initialization and raises aValueErrorfor unsupported formats.
Event Handlers
Deepgram TTS supports the standard service connection events:| Event | Description |
|---|---|
on_connected | Connected to Deepgram WebSocket |
on_disconnected | Disconnected from Deepgram WebSocket |
on_connection_error | WebSocket connection error occurred |