UploadAudioData

Updated at:

Uploads offline voice quality inspection data (recording session files). This operation is applicable to hotline agent scenarios. Scenario 1: Natively integrates with Alibaba Cloud Call Center (CCC), requiring no development. You can enable one-click push of call data to SCA. Scenario 2: Integrates with your own call center system. Each time the call center generates a recording, it pushes the recording to SCA for analysis.

Operation description

Process description

Call the API to upload audio quality inspection => Convert the recording file to text => Separate roles in the text based on the specified channel splitting method (distinguish between agent and customer) => Analyze using quality inspection rules => Quality inspection complete.

Task execution efficiency

The speed of task execution depends on the speed of converting the recording file to text. Ideally, a 5-minute recording file can be transcribed within 2 minutes. However, when the transcription service has many queued tasks, there will be a queuing wait time. Generally, transcription completes within 6 hours, except for bulk uploads of large-scale data (more than 500 hours of recordings uploaded within 30 minutes). After transcription is complete, quality inspection analysis takes only milliseconds.

Recording file URL requirements

  • Supports single-channel/dual-channel WAV and MP3 format recording files. The file size must be less than 512 MB.

  • The URL must be an HTTP-accessible URL address. Local file submission is not supported. The recording file access permissions must be set to public.

  • The URL can only use domain names, not IP addresses. The URL cannot contain spaces. Avoid using Chinese characters.

  • After converting the recording to text, the system deletes the downloaded recording file and does not retain a copy.

  • If your recording URL has an access expiration period (for example, the recording is stored in Alibaba Cloud OSS and you specified an expiration period when generating the recording URL through OSS), set the expiration period to at least 12 hours, or 24 hours if possible. This is because file transcription takes time and occasional queuing may occur. If the queuing time is long, the recording is downloaded only when transcription begins. This prevents the recording URL from expiring before the download.

  • After quality inspection analysis is complete, the recording is still played using the URL you provided when reviewing files in the console. Ensure that the URL remains active long-term. Otherwise, the recording cannot be played.

Role separation description

After the recording is converted to text, the system automatically separates the text into two conversation roles. However, the system cannot determine which role is the agent and which is the customer. You need to perform role separation based on certain rules. The accuracy of role separation is critical because the rules used for quality inspection analysis often have role detection restrictions (a rule only checks the agent or the customer). If role separation is incorrect, the accuracy of quality inspection results is significantly affected.

Recording files are typically divided into two types: single-channel (mono) and dual-channel (stereo):

  • Single-channel recording: The voices of both the agent and customer are stored on one channel. After the recording file is converted to text, the system uses a built-in algorithm to distinguish between two roles. By setting a list of keywords that the agent is likely to say, the system analyzes the transcribed text sentence by sentence from top to bottom. When a sentence matches a keyword, the role of that sentence is determined to be the agent, and the other role is the customer. For details, see recognizeRoleDataSetId and serviceChannelKeywords in the request parameters. Due to the unpredictability of conversation content (for example, cross-talk between two roles or both people speaking simultaneously), role separation for single-channel recordings cannot be guaranteed to be 100% accurate. Save recording files as dual-channel recordings whenever possible.

  • Dual-channel recording: The voices of the agent and customer are stored on two separate channels. Even if the conversation overlaps, the recording-to-text conversion can accurately distinguish between the two. Specify the agent and customer by using the serviceChannel and clientChannel request parameters.

Retrieve quality inspection analysis results

Because recording file recognition is not real-time, you need to asynchronously retrieve quality inspection analysis results. The following three methods are available:

  • Message notification: For details, see MSMQ. After receiving a message, invoke the GetResult operation to retrieve detailed results. (Recommended)

  • Callback: Specify a callbackUrl in the request parameters. The system initiates a callback after the task is complete. After receiving the callback, invoke the GetResult operation to retrieve detailed results.

  • Polling: The operation returns a task ID (taskId). Use the taskId to poll the getResult operation to asynchronously retrieve results. Check whether the status in the response parameters indicates completion. Do not set the polling interval too short. Analysis normally completes within a few minutes. Set the polling interval to 30 seconds or more. (Not recommended)

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

sca:UploadAudioData

create

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

JsonStr

string

Yes

The complete JSON string. For details about the content, see the following detailed information.

{“callList”:“xxxxx”}

BaseMeAgentId

integer

No

The business space ID. In multi-business space scenarios, this parameter specifies the business space to use. Default value: the default business space.

123456

Request parameters and JSON string information

PropertyTypeRequiredDescription
callListListYesThe collection of voice files. You can upload multiple recording files at a time. For details, see jsonStr.callList property description below.
autoSplitIntegerNoApplicable to single-channel recordings in most cases. Valid values: 0, 1. Specifies whether to automatically split channels. 1 indicates automatic channel splitting, and 0 indicates no splitting. Default value: 1. If set to 1, the uploaded audio is single-channel. Automatic channel splitting requires additional processing time. If the recording is dual-channel, this parameter must be set to 0.
enableAutoSplitByLLMBooleanNoSpecifies whether to use LLM-based automatic role separation parameter settings for this recording file. If set to true, the LLM intelligent role separation feature is used. Default value: false.
recognizeRoleDataSetIdLongNoThe dataset ID. Uses an existing dataset because the dataset has role separation rules configured at creation (see Speaker Role Settings in the Create Dataset feature). Specifying a dataset ID here applies the role separation rules of that dataset to the uploaded file. Applicable to single-channel recordings.
serviceChannelKeywordsListNoApplicable to single-channel recordings in most cases. Sets a list of keywords that the agent is likely to say (ensure the keywords are highly distinctive). The system analyzes the transcribed text sentence by sentence from top to bottom. When a sentence hits a keyword, the role of that sentence is determined to be the agent, and the other role is the customer. When both recognizeRoleDataSetId and serviceChannelKeywords are specified, recognizeRoleDataSetId takes higher priority. If neither is set, the system uses built-in channel splitting rules as a fallback.
serviceChannelIntegerNoApplicable to dual-channel recordings. Specifies the channel number of the agent role. Valid values: 0, 1. Default value: 0, meaning channel 0 is the agent. Channels are typically numbered starting from 0, so two channels are 0 and 1. Determine whether channel 0 is the agent or customer on your own. If you use this parameter, you must also pass the autoSplit parameter with a value of 0. Ignore this parameter for single-channel files.
clientChannelIntegerNoApplicable to dual-channel recordings. Specifies the channel number of the customer role. Valid values: 0, 1. Default value: 1, meaning channel 1 is the customer. Channels are typically numbered starting from 0, so two channels are 0 and 1. Determine whether channel 0 is the agent or customer on your own. If you use this parameter, you must also pass the autoSplit parameter with a value of 0. Ignore this parameter for single-channel files.
sampleRateIntegerNoThe sample rate of the recording file. Valid values: 8 (8000 Hz), 16 (16000 Hz). Default value: 8. Specify the correct sample rate for the recording file. An incorrect sample rate causes incorrect transcription results. Recordings generated by call centers typically have a sample rate of 8000 Hz.
callbackUrlStringNoThe callback URL. If not specified, no callback is initiated. Ensure the callback URL is publicly accessible over the Internet. IP addresses are not supported. A callback is initiated after recording analysis is complete. For details, see Callback parameter description below.

jsonStr.callList property description

PropertyTypeRequiredDescription
voiceFileUrlStringYesThe recording file URL. For specific requirements, see Recording file URL requirements in the API description.
fileNameStringNoThe audio file name, such as audio.wav. Although not required, provide this parameter for statistical purposes. If not provided, the name is extracted from voiceFileUrl. For example, for http://www.aliyun.com/audio.wav, the file name is parsed as audio.wav.
autoSplitIntegerNoSee the parent object metric description. If empty, the value from the parent object is used.
recognizeRoleDataSetIdLongNoSee the parent object metric description. If empty, the value from the parent object is used.
serviceChannelIntegerNoSee the parent object metric description. If empty, the value from the parent object is used.
clientChannelIntegerYesSee the parent object metric description. If empty, the value from the parent object is used.
sampleRateIntegerNoSee the parent object metric description. If empty, the value from the parent object is used.
callStartTimeLongNoThe time when the recording occurred, in milliseconds since January 1, 1970, 00:00:00 GMT (millisecond timestamp, for example: 1584535485856). If not specified, the current time is used.
customerServiceIdLongNoThe agent ID. Obtain this from the console under Basic Settings > Personnel Management. When the correct agent ID is provided, the agent can view associated recording files when logging in to the control tower.
customerServiceNameStringNoThe agent name.
skillGroupIdStringNoThe skill group ID.
skillGroupNameStringNoThe skill group name.
callTypeIntegerNoThe call type. Valid values: 1: outbound. 3: inbound.
calleeStringNoThe callee number. For outbound calls, this is the customer number. For inbound calls, this is the agent number.
callerStringNoThe caller number. For outbound calls, this is the agent number. For inbound calls, this is the customer number.
callIdStringNoThe call ID. This can be the call ID from the call center system or any other ID that identifies the call.
businessStringNoThe business line name. This is custom data used for classification and statistics.
callUuidStringNoThe globally unique identifier used for idempotency (deduplication). If this field is provided, the system checks whether the same callUuid exists in data uploaded within the last two hours. If it exists, the current upload request is rejected.
sessionGroupIdStringNoThe session group ID. Typically, sessions between the same agent and the same customer are called a session group. After providing a session group ID, you can view quality inspection results at the session group level on the session group results page. (Applicable to the new version of Intelligent Speech Analytics only)
customerIdStringNoThe customer ID. (Applicable to the new version of Intelligent Speech Analytics only)
customerNameStringNoThe customer name. (Applicable to the new version of Intelligent Speech Analytics only)
schemeTaskConfigIdStringNoThe manually specified quality inspection task ID. When manually specified, the specified quality inspection task is used for inspection. (Applicable to the new version of Intelligent Speech Analytics only)
remark1StringNoCustom data 1. Stores custom fields related to your business. Maximum length: 64 characters.
remark2StringNoCustom data 2. Stores custom fields related to your business. Maximum length: 64 characters.
remark3StringNoCustom data 3. Stores custom fields related to your business. Maximum length: 64 characters.
remark4StringNoCustom data 4. Stores custom fields related to your business. Maximum length: 64 characters.
remark5LongNoCustom data 5. Stores custom fields related to your business. Format: signed long.
remark6StringNoCustom data 6. Stores custom fields related to your business. Maximum length: 1024 characters.
remark7StringNoCustom data 7. Stores custom fields related to your business. Maximum length: 64 characters.
remark8StringNoCustom data 8. Stores custom fields related to your business. Maximum length: 64 characters.
remark9StringNoCustom data 9. Stores custom fields related to your business. Maximum length: 64 characters.
remark10StringNoCustom data 10. Stores custom fields related to your business. Maximum length: 64 characters.
remark11StringNoCustom data 11. Stores custom fields related to your business. Maximum length: 64 characters.
remark12StringNoCustom data 12. Stores custom fields related to your business. Maximum length: 64 characters.
remark13StringNoCustom data 13. Stores custom fields related to your business. Maximum length: 64 characters.
remark14LongNoCustom data 14. Stores custom fields related to your business. Format: signed long.
remark15LongNoCustom data 15. Stores custom fields related to your business. Format: signed long.
remark16StringNoCustom data 16. Stores custom fields related to your business. Maximum length: 64 characters.
remark17StringNoCustom data 17. Stores custom fields related to your business. Maximum length: 64 characters.
remark18StringNoCustom data 18. Stores custom fields related to your business. Maximum length: 64 characters.
remark19StringNoCustom data 19. Stores custom fields related to your business. Maximum length: 64 characters.
remark20StringNoCustom data 20. Stores custom fields related to your business. Maximum length: 64 characters.
remark21StringNoCustom data 21. Stores custom fields related to your business. Maximum length: 64 characters.
remark22StringNoCustom data 22. Stores custom fields related to your business. Maximum length: 64 characters.
remark23StringNoCustom data 23. Stores custom fields related to your business. Maximum length: 64 characters.
remark24StringNoCustom data 24. Stores custom fields related to your business. Maximum length: 64 characters.
remark25StringNoCustom data 25. Stores custom fields related to your business. Maximum length: 64 characters.
jsonParamStrStringNoAdditional custom fields in JSON string format. The key is the field name and the value is the field content. Example: {"CustomerLevel":3,"Channel":"OfficialWebsite"}.

Callback parameter description

Assume the callback URL provided by the caller is http://aliyun.com/callback. The complete URL during callback is http://aliyun.com/callback?taskId=xxx&timestamp=xxx&aliUid=xxx&signature=xxx&event=xxx, where:

  • taskId: The task ID.

  • timestamp: The UNIX timestamp at the time of the invocation, in milliseconds.

  • aliUid: The Alibaba Cloud account ID of the caller.

  • signature: The signature. The caller can use this to verify that the request originates from Alibaba Cloud. Calculation: Perform MD5 + Base64 encryption on taskId=xxx&timestamp=xxx&aliUid=xxx. Note the order. After receiving the callback, the caller can obtain taskId and timestamp from the callback URL. aliUid is the Alibaba Cloud account ID. Compare the self-calculated signature with the signature in the URL to verify consistency. See the Java code example below.

  • event: The event name. The caller can use this to determine which event triggered the callback. Valid values: TaskComplete (callback when the task is complete).

public static void signature() {
    long timestamp = System.currentTimeMillis();
    String taskId = "xxx";
    String aliUid = "xxx";
    // Perform MD5 + Base64 encryption on taskId=xxx&timestamp=xxx&aliUid=xxx and place it in the signature field
    String signature;
    try {
        signature = URLEncoder.encode(md5Base64("taskId=" + taskId + "&timestamp=" + timestamp + "&aliUid=" + aliUid), "utf-8");
        System.out.println(signature);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

public static String md5Base64(String str) throws NoSuchAlgorithmException {
    //string encoding must be utf-8
    byte[] utfBytes = str.getBytes(StandardCharsets.UTF_8);
    MessageDigest mdTemp = MessageDigest.getInstance("MD5");
    mdTemp.update(utfBytes);
    byte[] md5Bytes = mdTemp.digest();
    return Base64.encodeBase64String(md5Bytes);
}

Request parameter example

{
    "autoSplit":1,
    "serviceChannelKeywords":[
        "留学",
        "客服老师"
    ],
    "callbackUrl":"https://123.123.com/sca-callback",
    "callList":[
        {
            "schemeTaskConfigId":"589",
            "voiceFileUrl":"https://sca-ccc-test.oss-cn-beijing.aliyuncs.com/****.wav",
            "fileName":"abc.wav",
            "callStartTime":"1584535485856",
            "customerServiceId":"30",
            "customerServiceName":"Aagent",
            "skillGroupId":"34sd24",
            "skillGroupName":"售前技能组",
            "callType":1,
            "callee":188888****,
            "caller":"0102323***",
            "callId":23456457**,
            "business":"售前一组",
            "remark1":"38 节大促"
        }
    ]
}

Request code example

public class sca {
    
    private static String ak = "YOUR_ACCESS_KEY_ID";
    private static String sk = "YOUR_ACCESS_KEY_SECRET";

    private static void uploadAudio() throws Exception {
        String json = "{\n" +
                "    \"autoSplit\":1,\n" +
                "    \"serviceChannelKeywords\":[\n" +
                "        \"留学\",\n" +
                "        \"客服老师\"\n" +
                "    ],\n" +
                "    \"callbackUrl\":\"https://123.123.com/sca-callback\",\n" +
                "    \"callList\":[\n" +
                "        {\n" +
                "            \"schemeTaskConfigId\":\"589\",\n" +
                "            \"voiceFileUrl\":\"https://sc.oss-cn-beijing.aliyuncs.com/****.wav\",\n" +
                "            \"fileName\":\"abc.wav\",\n" +
                "            \"callStartTime\":\"1584535485856\",\n" +
                "            \"customerServiceId\":\"30\",\n" +
                "            \"customerServiceName\":\"Aagent\",\n" +
                "            \"skillGroupId\":\"34sd24\",\n" +
                "            \"skillGroupName\":\"售前技能组\",\n" +
                "            \"callType\":1,\n" +
                "            \"callee\":188888****,\n" +
                "            \"caller\":\"0102323***\",\n" +
                "            \"callId\":23456457**,\n" +
                "            \"business\":\"售前一组\",\n" +
                "            \"remark1\":\"38 节大促\"\n" +
                "        }\n" +
                "    ]\n" +
                "}";


        Config config = new Config();
        config.setAccessKeyId(ak).setAccessKeySecret(sk).setEndpoint("qualitycheck.cn-hangzhou.aliyuncs.com")
                .setRegionId("cn-hangzhou").setProtocol("HTTPS");

        Client client = new Client(config);
        UploadAudioDataRequest result = new UploadAudioDataRequest();

        result.setJsonStr(json);

        UploadAudioDataResponse response = client.uploadAudioData(result);
        System.out.println(JSONObject.toJSONString(response));
    }


    public static void main(String[] args) throws Exception {
        uploadAudio();
    }
}

Response elements

Element

Type

Description

Example

object

The response parameters.

Code

string

The response code. A value of 200 indicates success. Other values indicate failure. You can use this field to determine the cause of failure.

200

Message

string

The error message when the request fails. The value is "successful" when the request succeeds.

successful

Data

string

The task ID, which is used when retrieving task results.

76DB5D8C-5BD9-42A7-B527-5AF3A5***

RequestId

string

The request ID, which uniquely identifies the request.

76DB5D8C-5BD9-42A7-B527-5AF3A5F8***

Success

boolean

Indicates whether the request is successful. Valid values:

  • true: The request is successful.

  • false/null: The request failed.

true

Examples

Success response

JSON format

{
  "Code": "200",
  "Message": "successful",
  "Data": "76DB5D8C-5BD9-42A7-B527-5AF3A5***",
  "RequestId": "76DB5D8C-5BD9-42A7-B527-5AF3A5F8***",
  "Success": true
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.