tencent cloud

Feedback

DescribeTaskStatus

Last updated: 2024-12-12 15:06:27

1. API Description

Domain name for API request: asr.intl.tencentcloudapi.com.

The recognition results can be obtained through callback or polling after the recording recognition request API is called.

  • ** Note: A task is valid for 24 hours. Do not query the results with tasks that have existed for more than 24 hours or use task ID as the unique business ID because duplicate TaskIds of different dates may exist. **
  • For the callback method, the results will be sent by using a POST request to the callback URL specified in the request after the recognition is completed. For more details, see [Callback Description] (https://www.tencentcloud.com/document/product/1093/52632?from_cn_redirect=1).
  • For the polling method, you need to actively provide the task ID to poll for recognition results. There are four possible results: success, waiting, in progress, and failure. For detailed information, see the content below.
  • The request method is HTTP POST, and Content-Type is "application/json; charset=utf-8".
  • For the signature method, see the content related to the signature method v3 in Public Parameters.
  • Default request frequency limit: 50 requests/second. If you want to increase the request frequency limit, submit a ticket.

A maximum of 50 requests can be initiated per second for this API.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common Params. The value used for this API: DescribeTaskStatus.
Version Yes String Common Params. The value used for this API: 2019-06-14.
Region No String Common Params. This parameter is not required.
TaskId Yes Integer Task ID obtained from the CreateRecTask API, which is used to obtain the task status and results.
** Note: A task is valid for 24 hours. Do not query the results with the tasks that have existed for more than 24 hours. **

3. Output Parameters

Parameter Name Type Description
Data TaskStatus Returned result of the recording recognition request.
RequestId String The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.

4. Example

Example1 Performing polling to obtain the result - task failed

Retrieve the recognition result through polling. The task fails. You can check the value of ErrorMsg in the returned result for the failure cause.

Input Example

POST / HTTP/1.1
Host: asr.intl.tencentcloudapi.com
Content-Type: application/json; charset=utf-8
X-TC-Version: 2019-06-14
X-TC-Region: ap-shanghai
X-TC-Action: DescribeTaskStatus
X-TC-Timestamp: 1599142563
Authorization: TC3-HMAC-SHA256 Credential=xxx/2020-09-03/asr/tc3_request, SignedHeaders=content-type;host, Signature=6647fa852c9329ac5aa355c68c838358139c2d941f4ed175dd5858978f5d79c8
Content-Length: 21
<Common request parameters>

{
    "TaskId": 522931820
}

Output Example

{
    "Response": {
        "RequestId": "8824366f-0e8f-4bd4-8924-af5e84127caa",
        "Data": {
            "TaskId": 522931820,
            "Status": 3,
            "StatusStr": "failed",
            "AudioDuration": 0,
            "Result": "",
            "ErrorMsg": "Failed to download audio file!",
            "ResultDetail": []
        }
    }
}

Example2 Performing polling to obtain the result - task successful

Retrieve the recognition result through polling. The task is successful, and the recognition result is returned.

Input Example

POST / HTTP/1.1
Host: asr.intl.tencentcloudapi.com
Content-Type: application/json; charset=utf-8
X-TC-Version: 2019-06-14
X-TC-Region: ap-shanghai
X-TC-Action: DescribeTaskStatus
X-TC-Timestamp: 1599142563
Authorization: TC3-HMAC-SHA256 Credential=xxx/2020-09-03/asr/tc3_request, SignedHeaders=content-type;host, Signature=6647fa852c9329ac5aa355c68c838358139c2d941f4ed175dd5858978f5d79c8
Content-Length: 21
<Common request parameters>

{
    "TaskId": 522931820
}

Output Example

{
    "Response": {
        "RequestId": "a73b14a6-5044-41cb-bf32-e735d5bd69de",
        "Data": {
            "TaskId": 9266418,
            "Status": 2,
            "StatusStr": "success",
            "AudioDuration": 2.38,
            "Result": "[0:0.020,0:2.380] Welcome to Tencent Cloud ASR,\n",
            "ResultDetail": [
                {
                    "FinalSentence": "Welcome to Tencent Cloud ASR,",
                    "SliceSentence": "Welcome to  Tencent Cloud  ASR,",
                    "StartMs": 20,
                    "EndMs": 2380,
                    "SpeechSpeed": 5.9,
                    "WordsNum": 4,
                    "EmotionalEnergy": 0,
                    "SpeakerId": 0,
                    "SilenceTime": 0,
                    "EmotionType": [
                        "happy"
                    ],
                    "Words": [
                        {
                            "OffsetStartMs": 120,
                            "OffsetEndMs": 780,
                            "Word": "Tencent Cloud"
                        },
                        {
                            "OffsetStartMs": 780,
                            "OffsetEndMs": 1530,
                            "Word": "ASR"
                        },
                        {
                            "OffsetStartMs": 1530,
                            "OffsetEndMs": 1860,
                            "Word": "Welcome to"
                        },
                        {
                            "OffsetStartMs": 1860,
                            "OffsetEndMs": 2250,
                            "Word": " "
                        }
                    ],
                }
            ],
            "ErrorMsg": ""
        }
    }
}

Example3 Performing polling to obtain the result - task waiting

Retrieve the recognition result through polling. The task is waiting, which means that the task is still in the queue. You need to wait patiently.

Input Example

POST / HTTP/1.1
Host: asr.intl.tencentcloudapi.com
Content-Type: application/json; charset=utf-8
X-TC-Version: 2019-06-14
X-TC-Region: ap-shanghai
X-TC-Action: DescribeTaskStatus
X-TC-Timestamp: 1599142563
Authorization: TC3-HMAC-SHA256 Credential=xxx/2020-09-03/asr/tc3_request, SignedHeaders=content-type;host, Signature=6647fa852c9329ac5aa355c68c838358139c2d941f4ed175dd5858978f5d79c8
Content-Length: 21
<Common request parameters>

{
    "TaskId": 522931820
}

Output Example

{
    "Response": {
        "RequestId": "8824366f-0e8f-4bd4-8924-af5e84127caa",
        "Data": {
            "TaskId": 522931820,
            "Status": 0,
            "StatusStr": "waiting",
            "AudioDuration": 0,
            "Result": "",
            "ErrorMsg": "",
            "ResultDetail": []
        }
    }
}

Example4 Performing polling to obtain the result - task in progress

Retrieve the recognition result through polling. The task is in progress, which means that recognition has started. You need to wait patiently.

Input Example

POST / HTTP/1.1
Host: asr.intl.tencentcloudapi.com
Content-Type: application/json; charset=utf-8
X-TC-Version: 2019-06-14
X-TC-Region: ap-shanghai
X-TC-Action: DescribeTaskStatus
X-TC-Timestamp: 1599142563
Authorization: TC3-HMAC-SHA256 Credential=xxx/2020-09-03/asr/tc3_request, SignedHeaders=content-type;host, Signature=6647fa852c9329ac5aa355c68c838358139c2d941f4ed175dd5858978f5d79c8
Content-Length: 21
<Common request parameters>

{
    "TaskId": 522931820
}

Output Example

{
    "Response": {
        "RequestId": "8824366f-0e8f-4bd4-8924-af5e84127caa",
        "Data": {
            "TaskId": 522931820,
            "Status": 1,
            "StatusStr": "doing",
            "AudioDuration": 0,
            "Result": "",
            "ErrorMsg": "",
            "ResultDetail": []
        }
    }
}

5. Developer Resources

SDK

TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

Error Code Description
FailedOperation.ErrorDownFile Failed to download the audio file.
FailedOperation.ErrorRecognize Recognition failed.
FailedOperation.NoSuchTask Incorrect task ID.
FailedOperation.ServiceIsolate Services are stopped due to overdue payments. Top up your Tencent Cloud account first.
FailedOperation.UserHasNoFreeAmount The resource package is used up. Enable post-payment or purchase a new resource package.
InternalError.FailAccessDatabase Failed to access the database.
InternalError.FailAccessRedis Failed to access Redis.
InvalidParameter Parameter error.
MissingParameter Parameters are missing
UnknownParameter Unknown parameter.
Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support