Text to Speech

Voice Cloning

Lip Sync Video

Other

Text to Speech (WebSocket)

Real-time speech generation via WebSocket connection, suitable for chatbots and other scenarios

WebSocket Real-time Text to Speech API

WebSocket Address

wss://fishspeech.live/v1/tts/ws?token=YOUR_API_TOKEN

Connection Flow

1. Connect and include API Key in URL
2. Server event: connection established
3. Client event: initialize TTS configuration
4. Server event: service ready
5. Client event: send text
6. Server event: audio data
7. Client event: stop processing

Client Events

// start event - initialize TTS configuration
{
  "event": "start",
  "token": "YOUR_API_TOKEN",
  "request": {
    "reference_id": "your_model_id",  // Optional, model ID
    "latency": "normal",              // Optional, latency mode: "normal" or "balanced"
    "format": "mp3",                  // Optional, audio format: "mp3" or "wav"
    "version": "s1"                   // Optional, TTS version: "v1", "v2", "s1"
  }
}

// text event - send text
{
  "event": "text",
  "text": "Text content to convert"
}

// stop event - stop current processing
{
  "event": "stop"
}

Server Events

// connected event - connection established
{
  "event": "connected",
  "message": "WebSocket connection established"
}

// ready event - service ready
{
  "event": "ready",
  "message": "TTS service ready"
}

// processing event - processing text
{
  "event": "processing",
  "text": "Processed text"
}

// audio event - audio metadata
{
  "event": "audio",
  "format": "mp3",
  "text": "Processed text"
}

// binary data - audio format
<Binary audio data>

// done event - processing completed
{
  "event": "done",
  "text": "Processed text"
}

// error event - error occurred
{
  "event": "error",
  "message": "Error information",
  "text": "Text content to convert"  // Optional
}

// stopped event - stop confirmed
{
  "event": "stopped"
}

Online Debug

WebSocket Debug

Status Log

No logs yet

Status Code Description

Status Code Description:
200 OK                  - Request successful
400 Bad Request         - Invalid request parameters
401 Unauthorized        - Invalid API Token
403 Forbidden          - Access forbidden
404 Not Found          - Resource not found
413 Payload Too Large  - Upload file too large
429 Too Many Requests  - Rate limit exceeded/Insufficient credits
500 Server Error       - Internal server error

Error Response Format:
{
  "error": string,      // Error message
  "details": string,    // Detailed error message (optional)
  "code": string       // Error code (optional)
}