Deepgram
The DeepgramTTSService provides ultra-low latency text-to-speech using the Deepgram Aura model. Engineered specifically for conversational AI, it offers human-like speed and quality.
Installation
To use Deepgram TTS, install the required dependencies:
pip install "piopiy-ai[deepgram]"
Prerequisites
- A Deepgram account and API key (Get yours here).
- Set your API key in your environment:
export DEEPGRAM_API_KEY="your_api_key_here"
Configuration
DeepgramTTSService Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | str | Required | Your Deepgram API key. |
voice | str | "aura-2-helena-en" | Deepgram voice/model ID. |
encoding | str | "linear16" | Audio encoding format. |
sample_rate | int | None | Audio sample rate in Hz. |
Usage
Basic Setup (WebSocket)
import os
from piopiy.services.deepgram.tts import DeepgramTTSService
tts = DeepgramTTSService(
api_key=os.getenv("DEEPGRAM_API_KEY"),
voice="aura-2-luna-en"
)
Notes
- Conversational Latency: Deepgram Aura is one of the fastest TTS models available, making it excellent for fast-paced bot interactions.
- Flush Command: When using the WebSocket service, Piopiy automatically sends a
Flushcommand when the LLM finishes its response to ensure the entire message is synthesized and sent immediately. - Interruption: Supports the
Clearcommand via WebSocket to immediately stop audio generation when a user interrupts the bot.