Skip to main content
WSS
This example streams and plays the returned audio in real time while also saving the complete audio file. Note: To enable real-time audio playback, you must first install the mpv player. Additionally, make sure to set your API Key in the environment variable MINIMAX_API_KEY.
Task Start Event
type:object

Sending the "task_start" event officially begins the speech synthesis task. The task is considered successfully started when the server returns a "task_started" event. Only after receiving this event can you send "task_continue" or "task_finish" events to the server.

Task Continue Event
type:object

After receiving the "task_started" event from the server, the task officially begins. You can send "task_continue" events to provide text for synthesis. Multiple "task_continue" events can be sent sequentially. If no new event is sent within 120 seconds after receiving the last result, the WebSocket connection will automatically close.

Task Finish Event
type:object

When the server receives the task_finish event, it waits for all tasks in the current queue to complete, then closes the WebSocket connection and ends the session.

Connected Success Event
type:object

Notification that T2A task has started

Task Started Event
type:object

Notification that T2A task has started

Task Continued Event
type:object

Notification that T2A task is continuing

Task Finished Event
type:object

Notification that T2A task has completed successfully

Task Failed Event
type:object

If the task_failed event is received, it indicates that the task has failed. In this case, the WebSocket connection must be closed, and the error should be handled.