Skip to main content
Paraformer-Realtime

Paraformer real-time speech recognition server-side events

Reference for the server-sent events that the Paraformer real-time speech recognition service pushes to clients over WebSocket. This topic documents the data structure and field semantics of the four event types: task-started, result-generated, task-finished, and task-failed.

Paraformer models are available only in the China North 2 (Beijing) region. Use an API key created in that region. See Regions and endpoints.
User guide: For model details and selection guidance, see Speech-to-text. Event interaction flow: For the event sequence diagram, see WebSocket API.

task-started

Description: The task has started successfully. The client can begin sending audio data.
{
    "header": {
        "task_id": "2bf83b9a-baeb-4fda-8d9a-xxxxxxxxxxxx",
        "event": "task-started",
        "attributes": {}
    },
    "payload": {}
}
ParameterTypeDescription
headerobject
header.task_idstringClient-generated task ID (UUID format).
header.eventstringEvent type. Always task-started.
header.attributesobjectAdditional attributes. Typically empty.
payloadobjectAlways {}.

result-generated

Description: Recognition result. Includes intermediate results (sentence_end=false) and final results (sentence_end=true).
{
  "header": {
    "task_id": "2bf83b9a-baeb-4fda-8d9a-xxxxxxxxxxxx",
    "event": "result-generated",
    "attributes": {}
  },
  "payload": {
    "output": {
      "sentence": {
        "begin_time": 170,
        "end_time": null,
        "text": "Okay, I got it.",
        "heartbeat": false,
        "sentence_end": true,
        "words": [
          {
            "begin_time": 170,
            "end_time": 295,
            "text": "Okay",
            "punctuation": ","
          },
          {
            "begin_time": 295,
            "end_time": 503,
            "text": "I",
            "punctuation": ""
          },
          {
            "begin_time": 503,
            "end_time": 711,
            "text": "got",
            "punctuation": ""
          },
          {
            "begin_time": 711,
            "end_time": 920,
            "text": "it",
            "punctuation": ""
          }
        ]
      }
    },
    "usage": {
      "duration": 3
    }
  }
}
ParameterTypeDescription
headerobject
header.task_idstringClient-generated task ID (UUID format).
header.eventstringEvent type. Always result-generated.
payloadobject
payload.outputobject
payload.output.usageobjectWhen payload.output.sentence.sentence_end is false (the current sentence has not ended), usage is null. When payload.output.sentence.sentence_end is true (the current sentence has ended), usage.duration indicates the billable duration of the current task.
payload.output.usage.durationintegerBillable task duration, in seconds.
payload.output.sentenceobject
payload.output.sentence.begin_timeintegerSentence start time, in milliseconds.
payload.output.sentence.end_timeintegerSentence end time, in milliseconds.
payload.output.sentence.textstringRecognized text.
payload.output.sentence.heartbeatbooleanIf true, you can skip this result (heartbeat packet).
payload.output.sentence.sentence_endbooleanWhether the sentence has ended (true=final result, false=intermediate result).
payload.output.sentence.emo_tagstringTip: - Only paraformer-realtime-8k-v2 supports this feature.
  • This feature requires semantic segmentation to be disabled. Set semantic_punctuation_enabled to false in the run-task event.
  • The emotion recognition result is returned only when payload.output.sentence.sentence_end is true.
Sentiment of the current sentence:
  • positive: Positive sentiment, such as happy or satisfied.
  • negative: Negative sentiment, such as angry or dejected.
  • neutral: No distinct sentiment.
payload.output.sentence.emo_confidencefloatTip: - Only paraformer-realtime-8k-v2 supports this feature.
  • This feature requires semantic segmentation to be disabled. Set semantic_punctuation_enabled to false in the run-task event.
  • The emotion recognition result is returned only when payload.output.sentence.sentence_end is true.
Emotion confidence score in the range [0.0, 1.0]. A higher value indicates greater confidence.
payload.output.sentence.wordsarray[object]Word-level timestamp information.
payload.output.sentence.words.begin_timeintegerWord start time, in milliseconds.
payload.output.sentence.words.end_timeintegerWord end time, in milliseconds.
payload.output.sentence.words.textstringRecognized text.
payload.output.sentence.words.punctuationstringPunctuation mark.

task-finished

Description: The task ended normally. You can close the connection or reuse it.
{
    "header": {
        "task_id": "2bf83b9a-baeb-4fda-8d9a-xxxxxxxxxxxx",
        "event": "task-finished",
        "attributes": {}
    },
    "payload": {
        "output": {},
        "usage": null
    }
}
ParameterTypeDescription
headerobject
header.task_idstringClient-generated task ID (UUID format).
header.eventstringEvent type. Always task-finished.
header.attributesobjectAdditional attributes. Typically empty.
payloadobjectThe contents can be ignored. Typically {}.

task-failed

Description: The task failed. The connection is closed and cannot be reused.
{
    "header": {
        "task_id": "2bf83b9a-baeb-4fda-8d9a-xxxxxxxxxxxx",
        "event": "task-failed",
        "error_code": "CLIENT_ERROR",
        "error_message": "request timeout after 23 seconds.",
        "attributes": {}
    },
    "payload": {}
}
ParameterTypeDescription
headerobject
header.task_idstringClient-generated task ID (UUID format).
header.eventstringEvent type. Always task-failed.
header.error_codestringDescription of the error type.
header.error_messagestringSpecific cause of the error.
header.attributesobjectAdditional attributes. Typically empty.
payloadobjectAlways {}.