Prerequisites
Create a Fish Audio account
Create a Fish Audio account
Sign up for a free Fish Audio account to get started with our API.
- Go to fish.audio/auth/signup
- Fill in your details to create an account, complete steps to verify your account.
- Log in to your account and navigate to the API section
Get your API key
Get your API key
Once you have an account, you’ll need an API key to authenticate your requests.
- Log in to your Fish Audio Dashboard
- Navigate to the API Keys section
- Click “Create New Key” and give it a descriptive name, set a expiration if desired
- Copy your key and store it securely
Overview
Usestream_websocket() for real-time text streaming with LLMs and live captions. The connection automatically buffers incoming text and generates audio as it becomes available.
Basic Usage
Stream text chunks and receive audio in real-time:For details on audio formats, voice selection, and advanced configuration options like
TTSConfig, see the Text-to-Speech guide.Using FlushEvent
Force immediate audio generation to create pauses usingFlushEvent:
See Text-to-Speech guide for detailed FlushEvent usage and advanced examples.
LLM Integration
WebSocket streaming is designed for integrating with LLM streaming responses. The TTS engine automatically buffers incoming text chunks and generates audio when it has enough context for natural speech:The WebSocket connection automatically buffers incoming text and generates audio when it has accumulated enough context for natural-sounding speech. You don’t need to manually batch tokens unless you want to force generation at specific points using
FlushEvent.Next Steps
Text-to-Speech
Learn about non-streaming TTS options, audio formats, TextEvent vs plain strings, and advanced configuration
Voice Cloning
Use custom voices in streams and learn about voice selection
TTS API Reference
Complete streaming API documentation
Best Practices
Production streaming optimization
Related Resources
- WebSocket Types - TextEvent, FlushEvent, and more
- Utils Reference - Audio playback utilities
- Error Handling - WebSocket exception handling
- Fine-grained Control - Advanced speech control



