Overview

LmntTTSService provides text-to-speech capabilities using LMNT’s WebSocket-based streaming API. It supports real-time audio generation with multiple voices and languages.

Installation

To use LmntTTSService, install the required dependencies:

pip install pipecat-ai[lmnt]

You’ll also need to set up your LMNT API key as an environment variable: LMNT_API_KEY

Configuration

Constructor Parameters

api_key
str
required

Your LMNT API key

voice_id
str
required

LMNT voice identifier

sample_rate
int
default: "24000"

Output audio sample rate in Hz

language
Language
default: "Language.EN"

Synthesis language

text_filter
BaseTextFilter
default: "None"

Modifies text provided to the TTS. Learn more about the available filters.

Output Frames

Control Frames

TTSStartedFrame
Frame

Signals start of speech synthesis

TTSStoppedFrame
Frame

Signals completion of speech synthesis

Audio Frames

TTSAudioRawFrame
Frame

Contains generated audio data with: - PCM audio format (16-bit) - Specified sample rate - Single channel (mono)

Error Frames

ErrorFrame
Frame

Contains LMNT API error information

Methods

See the TTS base class methods for additional functionality.

Language Support

Supports multiple languages and regional variants:

Language CodeDescriptionService Code
Language.DEGermande
Language.ENEnglish (US)en
Language.EN_AUEnglish (Australia)en
Language.EN_GBEnglish (UK)en
Language.EN_INEnglish (India)en
Language.EN_NZEnglish (New Zealand)en
Language.ESSpanishes
Language.FRFrenchfr
Language.FR_CAFrench (Canada)fr
Language.KOKoreanko
Language.PTPortuguesept
Language.PT_BRPortuguese (Brazil)pt
Language.ZHChinese (Simplified)zh
Language.ZH_TWChinese (Traditional)zh

Usage Example

from pipecat.services.lmnt import LmntTTSService
from pipecat.transcriptions.language import Language

# Configure service
tts_service = LmntTTSService(
    api_key="your-lmnt-api-key",
    voice_id="your-voice-id",
    sample_rate=24000,
    language=Language.EN
)

# Use in pipeline
pipeline = Pipeline([
    text_input,         # Produces text
    tts_service,        # Converts text to speech
    audio_output        # Plays audio
])

Frame Flow

Metrics Support

The service collects processing metrics:

  • Time to First Byte (TTFB)
  • Processing duration
  • Character usage
  • WebSocket connection status

Notes

  • Supports streaming synthesis
  • Handles WebSocket lifecycle
  • Provides real-time audio chunks
  • Manages connection state
  • Supports interruptions
  • Thread-safe processing
  • Automatic error handling
  • Includes metrics collection