Overview
Async provides two TTS service implementations:AsyncAITTSService
: WebSocket-based streaming TTS with interruption supportAsyncAIHttpTTSService
: HTTP-based streaming TTS service for simpler synthesis
AsyncAITTSService
is recommended for real-time applications.API Reference
Complete API documentation and method details
Async Docs
Official Async documentation
Example Code
Working example with WebSocket streaming and interruption handling
Installation
To use Async services, install the required dependencies:ASYNCAI_API_KEY
.
Get your API key by signing up at async.
Frames
Input
TextFrame
- Text content to synthesize into speechTTSSpeakFrame
- Text that the TTS service should speakTTSUpdateSettingsFrame
- Runtime configuration updates (e.g., voice)LLMFullResponseStartFrame
/LLMFullResponseEndFrame
- LLM response boundaries
Output
TTSStartedFrame
- Signals start of synthesisTTSAudioRawFrame
- Generated audio data chunksTTSStoppedFrame
- Signals completion of synthesisErrorFrame
- Connection or processing errors
Service Comparison
Feature | AsyncAITTSService (WebSocket) | AsyncAIHttpTTSService (HTTP) |
---|---|---|
Streaming | ✅ Low-latency chunks | ✅ Response streaming |
Interruption | ✅ Advanced handling | ⚠️ Basic support |
Latency | 🚀 Low | 📈 Higher |
Connection | WebSocket persistent | HTTP per-request |
Language Support
Async currently supports:Language Code | Description | Service Code |
---|---|---|
Language.EN | English | en |
Async is expanding language support. Check the official
documentation for the latest available languages.
Usage Example
WebSocket Service (Recommended)
Initialize the WebSocket service with your API key and desired voice:HTTP Service
Initialize theAsyncAIHttpTTSService
and use it in a pipeline:
Dynamic Configuration
Make settings updates by pushing anTTSUpdateSettingsFrame
for either service:
Metrics
Both services provide:- Time to First Byte (TTFB) - Latency from text input to first audio
- Processing Duration - Total synthesis time
- Usage Metrics - Character count and synthesis statistics
Learn how to enable Metrics in your Pipeline.
Additional Notes
- WebSocket Recommended: Use
AsyncAITTSService
for low-latency streaming cases - Connection Management: WebSocket maintains persistent connection with automatic keepalive (10-second intervals)
- Sample Rate: Set globally in
PipelineParams
rather than per-service for consistency