Text-to-speech service implementation using Groq’s TTS API
GroqTTSService
converts text to speech using Groq’s TTS API. It supports real-time audio generation with multiple voices.
To use GroqTTSService
, install the required dependencies:
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.
Your Groq API key
Audio output format
Configuration parameters for speech generation
TTS model to use. See the Groq Cloud docs for available models.
Voice identifier to use for synthesis
Language for speech synthesis
Speech rate multiplier (higher values produce faster speech)
Random seed for reproducible audio generation
The service accepts text input through the pipeline, including streaming text from an LLM service.
Signals the start of audio generation.
Contains generated audio data:
Raw audio data chunk
Audio sample rate, based on the constructor setting
Number of audio channels (1 for mono)
Signals the completion of audio generation.
See the TTS base class methods for additional functionality.
GroqTTSService
supports the following languages:
Language Code | Description | Service Codes |
---|---|---|
Language.EN | English | en |
The service supports metrics collection:
Text-to-speech service implementation using Groq’s TTS API
GroqTTSService
converts text to speech using Groq’s TTS API. It supports real-time audio generation with multiple voices.
To use GroqTTSService
, install the required dependencies:
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.
Your Groq API key
Audio output format
Configuration parameters for speech generation
TTS model to use. See the Groq Cloud docs for available models.
Voice identifier to use for synthesis
Language for speech synthesis
Speech rate multiplier (higher values produce faster speech)
Random seed for reproducible audio generation
The service accepts text input through the pipeline, including streaming text from an LLM service.
Signals the start of audio generation.
Contains generated audio data:
Raw audio data chunk
Audio sample rate, based on the constructor setting
Number of audio channels (1 for mono)
Signals the completion of audio generation.
See the TTS base class methods for additional functionality.
GroqTTSService
supports the following languages:
Language Code | Description | Service Codes |
---|---|---|
Language.EN | English | en |
The service supports metrics collection: