Overview

GroqTTSService converts text to speech using Groq’s TTS API. It supports real-time audio generation with multiple voices.

Installation

To use GroqTTSService, install the required dependencies:

pip install "pipecat-ai[groq]"

You’ll also need to set up your Groq API key as an environment variable: GROQ_API_KEY.

You can obtain a Groq Cloud API key by signing up at Groq.

Configuration

Constructor Parameters

api_key
str
required

Your Groq API key

output_format
str
default:"wav"

Audio output format

params
InputParams
default:"InputParams()"

Configuration parameters for speech generation

model_name
str
default:"playai-tts"

TTS model to use. See the Groq Cloud docs for available models.

voice_id
str
default:"Celeste-PlayAI"

Voice identifier to use for synthesis

Input Parameters

language
Language
default:"Language.EN"

Language for speech synthesis

speed
float
default:"1.0"

Speech rate multiplier (higher values produce faster speech)

seed
Optional[int]
default:"None"

Random seed for reproducible audio generation

Input

The service accepts text input through the pipeline, including streaming text from an LLM service.

Output Frames

TTSStartedFrame

Signals the start of audio generation.

TTSAudioRawFrame

Contains generated audio data:

audio
bytes

Raw audio data chunk

sample_rate
int

Audio sample rate, based on the constructor setting

num_channels
int

Number of audio channels (1 for mono)

TTSStoppedFrame

Signals the completion of audio generation.

Methods

See the TTS base class methods for additional functionality.

Language Support

GroqTTSService supports the following languages:

Language CodeDescriptionService Codes
Language.ENEnglishen

Usage Example

from pipecat.services.groq import GroqTTSService
from pipecat.transcriptions.language import Language

# Configure service
tts = GroqTTSService(
    api_key="your-api-key",
    model_name="playai-tts",
    voice_id="Celeste-PlayAI",
    params=GroqTTSService.InputParams(
        language=Language.EN,
        speed=1.0,
        seed=42
    )
)

# Use in pipeline
pipeline = Pipeline([
    ...,
    llm,
    tts,
    transport.output(),
])

Frame Flow

Metrics Support

The service supports metrics collection:

  • Time to First Byte (TTFB)
  • Processing duration

Audio Processing

  • Streams audio in chunks
  • Outputs mono audio at the defined sample rate
  • Handles WAV header removal automatically
  • Supports WAV format by default

Notes

  • Requires a Groq Cloud API key
  • Streams audio in chunks for efficient processing
  • Automatically handles WAV headers in the response
  • Provides metrics collection
  • Supports configurable speech parameters