Skip to main content
Realtime

Fun-ASR client events

WebSocket client event reference for Fun-ASR real-time speech recognition

Client events are WebSocket commands that the client sends to the Fun-ASR real-time speech recognition service: run-task starts a recognition task, and finish-task ends it. User guide: For model details and selection guidance, see Speech-to-text models. Event sequence: For the event interaction diagram, see WebSocket API.

run-task

Description: Starts a speech recognition task. Sets the model, audio format, sample rate, and other parameters. When to send: Immediately after the WebSocket connection is established. Response: The client can send audio only after the service returns a task-started event.
Example
{
  "header": {
    "action": "run-task",
    "task_id": "2bf83b9a-baeb-4fda-8d9a-xxxxxxxxxxxx",
    "streaming": "duplex"
  },
  "payload": {
    "task_group": "audio",
    "task": "asr",
    "function": "recognition",
    "model": "fun-asr-realtime",
    "parameters": {
      "format": "pcm",
      "sample_rate": 16000
    },
    "input": {}
  }
}
object
body
required
Message header.
object
body
required
Message payload.

finish-task

Description: Notifies the service that all audio has been sent and requests that the service finish the task. When to send: After all audio data has been sent. Response: The service returns a task-finished event.
Example
{
  "header": {
    "action": "finish-task",
    "task_id": "2bf83b9a-baeb-4fda-8d9a-xxxxxxxxxxxx",
    "streaming": "duplex"
  },
  "payload": {
    "input": {}
  }
}
object
body
required
Message header.
object
body
required
Message payload.