{
"event": "start",
"request": {
"text": "",
"format": "mp3",
"chunk_length": 200,
"reference_id": "802e3bc2b27e49c2995d23ef70e6ac89",
"latency": "balanced"
}
}{
"event": "text",
"text": "Hello, this is streaming text. "
}{
"event": "flush"
}{
"event": "stop"
}{
"event": "audio",
"audio": "<binary audio data>"
}{
"event": "finish",
"reason": "stop"
}Real-time text-to-speech streaming via WebSocket
{
"event": "start",
"request": {
"text": "",
"format": "mp3",
"chunk_length": 200,
"reference_id": "802e3bc2b27e49c2995d23ef70e6ac89",
"latency": "balanced"
}
}{
"event": "text",
"text": "Hello, this is streaming text. "
}{
"event": "flush"
}{
"event": "stop"
}{
"event": "audio",
"audio": "<binary audio data>"
}{
"event": "finish",
"reason": "stop"
}API key authentication using Bearer token.
Get your API key from https://fish.audio/app/api-keys
Pass the token in the Authorization header:
Authorization: Bearer YOUR_API_KEY
TTS model to use for this session
Initiates a TTS streaming session with configuration.
This must be the first message sent after connecting. It contains all the configuration for voice, audio format, and generation parameters.
Sends a chunk of text for synthesis.
You can send multiple TextEvent messages in sequence. The server will buffer and synthesize text according to the chunk_length parameter from StartEvent.
Forces immediate synthesis of all buffered text.
Use this when you want audio generated immediately without waiting for more text or for the buffer to fill up. Useful for ensuring low latency in interactive applications.
Signals the end of the text stream.
After sending this event, the server will finish synthesizing any remaining buffered text and send a FinishEvent before closing the connection.
Contains generated audio bytes.
You will receive multiple AudioEvent messages as audio is generated. Each message contains a chunk of audio in the format you specified. Concatenate all chunks to get the complete audio.
Signals that the TTS session has completed.
The WebSocket connection will close after this event.
Was this page helpful?