LMNT
Text-to-speech service implementation using LMNT’s streaming API
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:
You’ll also need to set up your LMNT API key as an environment variable: LMNT_API_KEY
Configuration
Constructor Parameters
Your LMNT API key
LMNT voice identifier
Output audio sample rate in Hz
Synthesis language
Modifies text provided to the TTS. Learn more about the available filters.
Output Frames
Control Frames
Signals start of speech synthesis
Signals completion of speech synthesis
Audio Frames
Contains generated audio data with: - PCM audio format (16-bit) - Specified sample rate - Single channel (mono)
Error Frames
Contains LMNT API error information
Methods
See the TTS base class methods for additional functionality.
Language Support
Supports multiple languages and regional variants:
Language Code | Description | Service Code |
---|---|---|
Language.DE | German | de |
Language.EN | English (US) | en |
Language.EN_AU | English (Australia) | en |
Language.EN_GB | English (UK) | en |
Language.EN_IN | English (India) | en |
Language.EN_NZ | English (New Zealand) | en |
Language.ES | Spanish | es |
Language.FR | French | fr |
Language.FR_CA | French (Canada) | fr |
Language.KO | Korean | ko |
Language.PT | Portuguese | pt |
Language.PT_BR | Portuguese (Brazil) | pt |
Language.ZH | Chinese (Simplified) | zh |
Language.ZH_TW | Chinese (Traditional) | zh |
Usage Example
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