Skip to main content

Deepgram 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

ParameterTypeDefaultDescription
api_keystrRequiredYour Deepgram API key.
voicestr"aura-2-helena-en"Deepgram voice/model ID.
encodingstr"linear16"Audio encoding format.
sample_rateintNoneAudio 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 Flush command when the LLM finishes its response to ensure the entire message is synthesized and sent immediately.
  • Interruption: Supports the Clear command via WebSocket to immediately stop audio generation when a user interrupts the bot.