Skip to main content

Overview

LMNTTTSService provides real-time text-to-speech synthesis through LMNT’s WebSocket-based streaming API optimized for conversational AI. The service offers ultra-low latency with high-quality voice models and supports multiple languages with automatic interruption handling.

Installation

To use LMNT services, install the required dependencies:
pip install "pipecat-ai[lmnt]"

Prerequisites

LMNT Account Setup

Before using LMNT TTS services, you need:
  1. LMNT Account: Sign up at LMNT Console
  2. API Key: Generate an API key from your account dashboard
  3. Voice Selection: Choose from available voice models or create custom voices

Required Environment Variables

  • LMNT_API_KEY: Your LMNT API key for authentication

Configuration

LmntTTSService

api_key
str
required
LMNT API key for authentication.
voice_id
str
required
ID of the voice to use for synthesis.
model
str
default:"blizzard"
LMNT TTS model to use.
language
Language
default:"Language.EN"
Language for synthesis. Supports multiple languages including German, English, Spanish, French, Hindi, and more.
sample_rate
int
default:"None"
Output audio sample rate in Hz. When None, uses the pipeline’s configured sample rate.

Usage

Basic Setup

from pipecat.services.lmnt import LmntTTSService

tts = LmntTTSService(
    api_key=os.getenv("LMNT_API_KEY"),
    voice_id="lily",
)

With Language Configuration

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

tts = LmntTTSService(
    api_key=os.getenv("LMNT_API_KEY"),
    voice_id="lily",
    model="blizzard",
    language=Language.ES,
)

Notes

  • WebSocket-based streaming: LMNT uses a persistent WebSocket connection for low-latency audio synthesis with automatic reconnection.
  • Class name: The Python class is LmntTTSService (note the lowercase ‘mnt’).

Event Handlers

LMNT TTS supports the standard service connection events:
EventDescription
on_connectedConnected to LMNT WebSocket
on_disconnectedDisconnected from LMNT WebSocket
on_connection_errorWebSocket connection error occurred
@tts.event_handler("on_connected")
async def on_connected(service):
    print("Connected to LMNT")