Creates a live subtitle task to transcribe an audio stream to text in real time.
Operation description
This operation creates a real-time caption task to transcribe an audio stream into text.
QPS limits
The queries per second (QPS) limit for this operation is 20 for each account. API calls that exceed this limit are throttled. To prevent your business from being affected, call this operation at a reasonable rate.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
live:CreateRtcAsrTask |
create |
*Domain
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| RegionId |
string |
No |
The region ID. |
cn-shanghai |
| Mode |
string |
Yes |
The stream type. Valid values: live and rtc. The value live specifies a regular live stream, such as a Real-Time Messaging Protocol (RTMP) stream. |
live |
| SDKAppID |
string |
No |
The ID of the Alibaba Real-Time Communication (ARTC) application. Note
This parameter is required and takes effect only if you set the Mode parameter to rtc. |
appId |
| ChannelID |
string |
No |
The channel ID. Note
This parameter is required and takes effect only if you set the Mode parameter to rtc. |
channelId |
| RtcUserId |
string |
No |
The ID of the user who ingests the stream. Note
This parameter is required and takes effect only if you set the Mode parameter to rtc. You can specify only one user ID. |
user1 |
| StreamURL |
string |
No |
The streaming URL. Note
This parameter is required and takes effect only if you set the Mode parameter to live. |
rtmp://xxx |
| Language |
string |
Yes |
The source language of the audio. Valid values:
|
cn |
| CallbackURL |
string |
Yes |
The callback URL. |
http://xxx.com |
| AuthKey |
string |
No |
The AuthKey that is used to generate the MD5 signature for callbacks. Note
Two authentication fields are added to the request header for callbacks. "SIG-TIME" indicates the current timestamp. "ASR-SIG" indicates the MD5 authentication field. The "ASR-SIG" field is generated based on the following rule: md5( |
abcd |
| TranslateEnabled |
boolean |
No |
Specifies whether to enable translation. |
true |
| TargetLanguages |
string |
No |
The target language for translation. Valid values:
|
en |
| AutoTerminateEnabled |
boolean |
No |
Specifies whether to automatically shut down the task if the stream is interrupted for longer than the allowed latency. Default value: false. |
true |
| AutoTerminateDelay |
integer |
No |
The maximum duration of a stream interruption before the task is automatically shut down. Unit: seconds. Valid values: 1 to 10. |
5 |
| ReportInterval |
integer |
No |
The interval for reporting callbacks. Unit: milliseconds. Valid values: -1 to 500.
|
5 |
Sample callbacks
The system sends an HTTP POST request to the specified callback URL. The request body contains data in JSON format. For more information about the Content parameter and the callback flow, see Interaction flow and implementation. The following code shows a sample callback:
{
"task_id": "asr-cf8c70d7-3b8d-496c-98f8-4785******",
"sdk_app_id": "",
"channel_id": "",
"rtc_user_id": "",
"callback_time_stamp": 1723433155645,
"language": "cn",
"content": "{\"header\":{\"nls_task_id\":\"af95c5cc332549f689f3153bc9******\",\"task_key\":\"tl_2977564_17234*****\",\"namespace\":\"SpeechTranscriber\",\"name\":\"TranscriptionResultChanged\",\"task_id\":\"413937911b874146b5796******\",\"message_id\":\"abfc9e9994e748a38499e1******\",\"status_text\":\"Success.\",\"status\":20000000},\"payload\":{\"result\":\"Meeting with you all here\",\"confidence\":0.0,\"words\":[{\"startTime\":0,\"text\":\"Meeting\",\"endTime\":510},{\"startTime\":510,\"text\":\"with\",\"endTime\":1020},{\"startTime\":1020,\"text\":\"you all\",\"endTime\":1530},{\"startTime\":1530,\"text\":\"here\",\"endTime\":2040}],\"index\":0,\"time\":2040,\"fixed_result\":\"\",\"unfixed_result\":\"\",\"status\":0}}"
}
Response parameters
|
Parameter |
Type |
Description |
Example |
|
object |
|||
| Description |
string |
The result description. A value of success indicates that the request was successful. Otherwise, an error message is returned. |
success |
| RequestId |
string |
The request ID. |
7FF5417D-06E9-5A2C-9A70-581F6149E6C1 |
| RetCode |
integer |
The status code. A value of 2000 indicates that the request was successful. Other values indicate that the request failed. |
2000 |
| TaskId |
string |
The ID of the task. |
asr-a6ac15e0-9118-4b4c-9e64-306163a0**** |
Examples
Success response
JSON format
{
"Description": "success",
"RequestId": "7FF5417D-06E9-5A2C-9A70-581F6149E6C1",
"RetCode": 2000,
"TaskId": "asr-a6ac15e0-9118-4b4c-9e64-306163a0****"
}
Error codes
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.