Todos os produtos
Search
Central de documentação

Alibaba Cloud Model Studio:Eventos do servidor Qwen-Audio-ASR-Streaming

Última atualização: Nov 16, 2026

Referência de eventos do servidor Qwen-Audio-ASR-Streaming: início da tarefa, resultados, conclusão, falha e solicitações correspondentes.

Fluxo de eventos

  1. Envie run-task. Aguarde task-started antes de enviar áudio.
  2. Continue enviando áudio enquanto recebe eventos result-generated.
  3. Após enviar todo o áudio, envie finish-task e receba os resultados até chegar task-finished. Uma tarefa com falha retorna task-failed.

O áudio não é enviado em run-task: o WebSocket usa quadros binários e o AOQ usa uma Audio Track. Para conexão, autenticação e transporte de áudio, consulte a API WebSocket ou o acesso AOQ.

task-started

Indica que a tarefa foi iniciada com sucesso e que o cliente pode começar a enviar áudio.

ImportanteAguarde task-started antes de enviar áudio. run-task apenas inicia e configura a tarefa; ele não contém dados de áudio.

headerobject
task_idstring

ID da tarefa gerado pelo cliente (formato UUID).

eventstring

Tipo do evento. Sempre task-started.

attributesobject

Atributos adicionais. Geralmente vazio.

payloadobject

Sempre {}.

{
  "header": {
    "action": "run-task",
    "task_id": "3d30b8aa-8859-46ef-a65a-32cf5a9f0ca4",
    "streaming": "duplex"
  },
  "payload": {
    "task_group": "audio",
    "task": "asr",
    "function": "recognition",
    "model": "qwen-audio-3.1-asr-flash-streaming",
    "parameters": {
      "format": "pcm",
      "sample_rate": 16000
    },
    "input": {}
  }
}
{
  "header": {
    "task_id": "3d30b8aa-8859-46ef-a65a-32cf5a9f0ca4",
    "task_uuid": "f32fbf86736e4c279b5d133bff74b657",
    "event": "task-started",
    "attributes": {}
  },
  "payload": {}
}

result-generated

Retorna resultados de reconhecimento, incluindo início de frase, resultados intermediários, resultados finais de frase e heartbeats.

Importantesentence_end=true indica o fim de uma frase, não da tarefa. Resultados de heartbeat (heartbeat=true) podem ser ignorados. A tarefa termina quando task-finished é recebido.

headerobject
task_idstring

ID da tarefa gerado pelo cliente (formato UUID).

eventstring

Tipo do evento. Sempre result-generated.

payloadobject
outputobject
sentenceobject
sentence_idinteger

Identificador sequencial da frase. Em resultados normais, sentence_id incrementa a partir de 1. Em pacotes de heartbeat (heartbeat=true), sentence_id é sempre 0.

begin_timeinteger

Horário de início da frase, em milissegundos.

end_timeinteger | null

Horário de término da frase, em milissegundos. Pode ser null em resultados intermediários ou heartbeats.

textstring

Texto reconhecido.

sentence_beginboolean

Indica o início de uma frase.

sentence_endboolean

Indica se a frase terminou (true = resultado final; false = resultado intermediário).

heartbeatboolean

Se true, o resultado é um pacote de heartbeat e pode ser ignorado.

wordsarray[object]

Carimbos de data/hora no nível da palavra.

begin_timeinteger

Horário de início da palavra, em milissegundos.

end_timeinteger

Horário de término da palavra, em milissegundos.

textstring

Texto reconhecido.

punctuationstring

Sinal de pontuação.

usageobject

Uso acumulado da tarefa atual.

Observaçãousage contém o uso acumulado da tarefa atual e pode estar ausente em alguns resultados intermediários. Não some os valores de usage entre eventos. qwen-audio-3.0-asr-flash-streaming é cobrado por duração e qwen-audio-3.1-asr-flash-streaming por tokens. Consulte a aplicabilidade na descrição de cada campo.

durationinteger

Duração acumulada do áudio, em segundos.

ObservaçãoUsado para o faturamento de qwen-audio-3.0-asr-flash-streaming.

input_tokensinteger

Número acumulado de tokens de entrada.

ObservaçãoAplica-se a qwen-audio-3.1-asr-flash-streaming.

output_tokensinteger

Número acumulado de tokens de saída.

ObservaçãoAplica-se a qwen-audio-3.1-asr-flash-streaming.

total_tokensinteger

Total acumulado de tokens, igual à soma dos tokens de entrada e saída.

ObservaçãoAplica-se a qwen-audio-3.1-asr-flash-streaming.

Início de frase

Após receber task-started, envie áudio. O exemplo abaixo é um evento result-generated retornado em seguida pelo servidor. O áudio é enviado por quadros binários WebSocket ou pela Audio Track AOQ.

{
  "header": {
    "action": "run-task",
    "task_id": "3d30b8aa-8859-46ef-a65a-32cf5a9f0ca4",
    "streaming": "duplex"
  },
  "payload": {
    "task_group": "audio",
    "task": "asr",
    "function": "recognition",
    "model": "qwen-audio-3.1-asr-flash-streaming",
    "parameters": {
      "format": "pcm",
      "sample_rate": 16000
    },
    "input": {}
  }
}
{
  "header": {
    "task_id": "3d30b8aa-8859-46ef-a65a-32cf5a9f0ca4",
    "event": "result-generated",
    "attributes": {}
  },
  "payload": {
    "output": {
      "sentence": {
        "sentence_id": 1,
        "begin_time": 0,
        "end_time": null,
        "text": "",
        "channel_id": 0,
        "sentence_end": false,
        "sentence_begin": true,
        "words": []
      },
      "text": "",
      "request_id": "3d30b8aa-8859-46ef-a65a-32cf5a9f0ca4",
      "output": {
        "sentence": {
          "sentence_id": 1,
          "begin_time": 0,
          "end_time": null,
          "text": "",
          "channel_id": 0,
          "sentence_end": false,
          "sentence_begin": true,
          "words": []
        },
        "text": "",
        "request_id": "3d30b8aa-8859-46ef-a65a-32cf5a9f0ca4"
      }
    }
  }
}

Resultado intermediário

Após receber task-started, envie áudio. O exemplo abaixo é um evento result-generated retornado em seguida pelo servidor. O áudio é enviado por quadros binários WebSocket ou pela Audio Track AOQ.

{
  "header": {
    "action": "run-task",
    "task_id": "3d30b8aa-8859-46ef-a65a-32cf5a9f0ca4",
    "streaming": "duplex"
  },
  "payload": {
    "task_group": "audio",
    "task": "asr",
    "function": "recognition",
    "model": "qwen-audio-3.1-asr-flash-streaming",
    "parameters": {
      "format": "pcm",
      "sample_rate": 16000
    },
    "input": {}
  }
}
{
  "header": {
    "task_id": "3d30b8aa-8859-46ef-a65a-32cf5a9f0ca4",
    "event": "result-generated",
    "attributes": {}
  },
  "payload": {
    "output": {
      "sentence": {
        "sentence_id": 1,
        "begin_time": 0,
        "end_time": null,
        "text": "Please",
        "channel_id": 0,
        "sentence_end": false,
        "words": [
          {
            "begin_time": 0,
            "end_time": 320,
            "text": "Please",
            "punctuation": "",
            "fixed": false,
            "speaker_id": null
          }
        ]
      },
      "text": "Please",
      "request_id": "3d30b8aa-8859-46ef-a65a-32cf5a9f0ca4",
      "output": {
        "sentence": {
          "sentence_id": 1,
          "begin_time": 0,
          "end_time": null,
          "text": "Please",
          "channel_id": 0,
          "sentence_end": false,
          "words": [
            {
              "begin_time": 0,
              "end_time": 320,
              "text": "Please",
              "punctuation": "",
              "fixed": false,
              "speaker_id": null
            }
          ]
        },
        "text": "Please",
        "request_id": "3d30b8aa-8859-46ef-a65a-32cf5a9f0ca4"
      }
    }
  }
}

Resultado final de frase

Após receber task-started, envie áudio. O exemplo abaixo é um evento result-generated retornado em seguida pelo servidor. O áudio é enviado por quadros binários WebSocket ou pela Audio Track AOQ.

{
  "header": {
    "action": "run-task",
    "task_id": "3d30b8aa-8859-46ef-a65a-32cf5a9f0ca4",
    "streaming": "duplex"
  },
  "payload": {
    "task_group": "audio",
    "task": "asr",
    "function": "recognition",
    "model": "qwen-audio-3.1-asr-flash-streaming",
    "parameters": {
      "format": "pcm",
      "sample_rate": 16000
    },
    "input": {}
  }
}
{
  "header": {
    "task_id": "3d30b8aa-8859-46ef-a65a-32cf5a9f0ca4",
    "event": "result-generated",
    "attributes": {}
  },
  "payload": {
    "output": {
      "sentence": {
        "sentence_id": 1,
        "begin_time": 120,
        "end_time": 3990,
        "text": "Please send the quarterly project report to Kellera before Friday. ",
        "channel_id": 0,
        "sentence_end": true,
        "words": [
          {
            "begin_time": 120,
            "end_time": 320,
            "text": "Please",
            "punctuation": "",
            "fixed": true,
            "speaker_id": null
          },
          {
            "begin_time": 320,
            "end_time": 560,
            "text": " send",
            "punctuation": "",
            "fixed": true,
            "speaker_id": null
          },
          {
            "begin_time": 560,
            "end_time": 760,
            "text": " the",
            "punctuation": "",
            "fixed": true,
            "speaker_id": null
          },
          {
            "begin_time": 760,
            "end_time": 1360,
            "text": " quarterly",
            "punctuation": "",
            "fixed": true,
            "speaker_id": null
          },
          {
            "begin_time": 1360,
            "end_time": 1800,
            "text": " project",
            "punctuation": "",
            "fixed": true,
            "speaker_id": null
          },
          {
            "begin_time": 1800,
            "end_time": 2120,
            "text": " report",
            "punctuation": "",
            "fixed": true,
            "speaker_id": null
          },
          {
            "begin_time": 2120,
            "end_time": 2280,
            "text": " to",
            "punctuation": "",
            "fixed": true,
            "speaker_id": null
          },
          {
            "begin_time": 2280,
            "end_time": 2336,
            "text": " ",
            "punctuation": "",
            "fixed": true,
            "speaker_id": null
          },
          {
            "begin_time": 2336,
            "end_time": 2560,
            "text": "Kell",
            "punctuation": "",
            "fixed": true,
            "speaker_id": null
          },
          {
            "begin_time": 2560,
            "end_time": 2800,
            "text": "era",
            "punctuation": "",
            "fixed": true,
            "speaker_id": null
          },
          {
            "begin_time": 2800,
            "end_time": 3160,
            "text": " before",
            "punctuation": "",
            "fixed": true,
            "speaker_id": null
          },
          {
            "begin_time": 3160,
            "end_time": 3990,
            "text": " Friday",
            "punctuation": ". ",
            "fixed": true,
            "speaker_id": null
          }
        ],
        "stash": {
          "sentence_id": 2,
          "text": "",
          "begin_time": 3990,
          "current_time": 3990,
          "words": []
        }
      },
      "text": "Please send the quarterly project report to Kellera before Friday. ",
      "request_id": "3d30b8aa-8859-46ef-a65a-32cf5a9f0ca4",
      "output": {
        "sentence": {
          "sentence_id": 1,
          "begin_time": 120,
          "end_time": 3990,
          "text": "Please send the quarterly project report to Kellera before Friday. ",
          "channel_id": 0,
          "sentence_end": true,
          "words": [
            {
              "begin_time": 120,
              "end_time": 320,
              "text": "Please",
              "punctuation": "",
              "fixed": true,
              "speaker_id": null
            },
            {
              "begin_time": 320,
              "end_time": 560,
              "text": " send",
              "punctuation": "",
              "fixed": true,
              "speaker_id": null
            },
            {
              "begin_time": 560,
              "end_time": 760,
              "text": " the",
              "punctuation": "",
              "fixed": true,
              "speaker_id": null
            },
            {
              "begin_time": 760,
              "end_time": 1360,
              "text": " quarterly",
              "punctuation": "",
              "fixed": true,
              "speaker_id": null
            },
            {
              "begin_time": 1360,
              "end_time": 1800,
              "text": " project",
              "punctuation": "",
              "fixed": true,
              "speaker_id": null
            },
            {
              "begin_time": 1800,
              "end_time": 2120,
              "text": " report",
              "punctuation": "",
              "fixed": true,
              "speaker_id": null
            },
            {
              "begin_time": 2120,
              "end_time": 2280,
              "text": " to",
              "punctuation": "",
              "fixed": true,
              "speaker_id": null
            },
            {
              "begin_time": 2280,
              "end_time": 2336,
              "text": " ",
              "punctuation": "",
              "fixed": true,
              "speaker_id": null
            },
            {
              "begin_time": 2336,
              "end_time": 2560,
              "text": "Kell",
              "punctuation": "",
              "fixed": true,
              "speaker_id": null
            },
            {
              "begin_time": 2560,
              "end_time": 2800,
              "text": "era",
              "punctuation": "",
              "fixed": true,
              "speaker_id": null
            },
            {
              "begin_time": 2800,
              "end_time": 3160,
              "text": " before",
              "punctuation": "",
              "fixed": true,
              "speaker_id": null
            },
            {
              "begin_time": 3160,
              "end_time": 3990,
              "text": " Friday",
              "punctuation": ". ",
              "fixed": true,
              "speaker_id": null
            }
          ],
          "stash": {
            "sentence_id": 2,
            "text": "",
            "begin_time": 3990,
            "current_time": 3990,
            "words": []
          }
        },
        "text": "Please send the quarterly project report to Kellera before Friday. ",
        "request_id": "3d30b8aa-8859-46ef-a65a-32cf5a9f0ca4"
      },
      "usage": {
        "duration": 4,
        "input_tokens": 50,
        "output_tokens": 13,
        "total_tokens": 63
      }
    },
    "usage": {
      "duration": 4,
      "input_tokens": 50,
      "output_tokens": 13,
      "total_tokens": 63
    }
  }
}

Heartbeat

Defina heartbeat=true em run-task e continue enviando áudio silencioso. O exemplo abaixo mostra um evento de heartbeat retornado pelo servidor.

{
  "header": {
    "action": "run-task",
    "task_id": "eac269a3-a31d-417a-979d-51066926d8a6",
    "streaming": "duplex"
  },
  "payload": {
    "task_group": "audio",
    "task": "asr",
    "function": "recognition",
    "model": "qwen-audio-3.1-asr-flash-streaming",
    "parameters": {
      "format": "pcm",
      "sample_rate": 16000,
      "heartbeat": true
    },
    "input": {}
  }
}
{
  "header": {
    "task_id": "eac269a3-a31d-417a-979d-51066926d8a6",
    "event": "result-generated",
    "attributes": {}
  },
  "payload": {
    "output": {
      "sentence": {
        "sentence_id": 0,
        "begin_time": 0,
        "end_time": null,
        "text": "",
        "channel_id": 0,
        "speaker_id": null,
        "sentence_end": false,
        "heartbeat": true,
        "words": []
      },
      "text": "",
      "request_id": "eac269a3-a31d-417a-979d-51066926d8a6",
      "output": {
        "sentence": {
          "sentence_id": 0,
          "begin_time": 0,
          "end_time": null,
          "text": "",
          "channel_id": 0,
          "speaker_id": null,
          "sentence_end": false,
          "heartbeat": true,
          "words": []
        },
        "text": "",
        "request_id": "eac269a3-a31d-417a-979d-51066926d8a6"
      }
    },
    "usage": {
      "duration": 2
    }
  }
}

task-finished

Indica que o processamento da tarefa foi concluído e todos os resultados de reconhecimento foram retornados.

headerobject
task_idstring

ID da tarefa gerado pelo cliente (formato UUID).

eventstring

Tipo do evento. Sempre task-finished.

attributesobject

Atributos adicionais. Geralmente vazio.

payloadobject
usageobject

Uso acumulado ao final da tarefa. Os campos têm o mesmo significado que em result-generated.usage.

{
  "header": {
    "action": "finish-task",
    "task_id": "3d30b8aa-8859-46ef-a65a-32cf5a9f0ca4",
    "streaming": "duplex"
  },
  "payload": {
    "input": {}
  }
}
{
  "header": {
    "task_id": "3d30b8aa-8859-46ef-a65a-32cf5a9f0ca4",
    "event": "task-finished",
    "attributes": {}
  },
  "payload": {
    "output": {},
    "usage": {
      "duration": 4,
      "input_tokens": 50,
      "output_tokens": 13,
      "total_tokens": 63
    }
  }
}

task-failed

Indica que a tarefa falhou. Verifique error_code e error_message para identificar a causa. Após a falha, a conexão WebSocket é fechada e não pode ser reutilizada.

headerobject
task_idstring

ID da tarefa gerado pelo cliente (formato UUID).

eventstring

Tipo do evento. Sempre task-failed.

error_codestring

Descrição do tipo de erro.

error_messagestring

Causa específica do erro.

attributesobject

Atributos adicionais. Geralmente vazio.

payloadobject

Sempre {}.

Esta solicitação usa um formato de áudio não compatível para demonstrar task-failed. O código e a mensagem de erro dependem da causa da falha.

{
  "header": {
    "action": "run-task",
    "task_id": "9272a5a2-8df4-4f2d-af0e-e544c17f3e42",
    "streaming": "duplex"
  },
  "payload": {
    "task_group": "audio",
    "task": "asr",
    "function": "recognition",
    "model": "qwen-audio-3.1-asr-flash-streaming",
    "parameters": {
      "format": "invalid-format",
      "sample_rate": 16000
    },
    "input": {}
  }
}
{
  "header": {
    "task_id": "9272a5a2-8df4-4f2d-af0e-e544c17f3e42",
    "event": "task-failed",
    "error_code": "UNSUPPORTED_FORMAT",
    "error_message": "UNSUPPORTED_FORMAT"
  },
  "payload": {}
}