UploadAudioData
Uploads offline voice quality inspection data (recorded session files) for hotline agent scenarios. Scenario 1: Natively integrates with Alibaba Cloud Cloud Call Center (CCC) without the need for development, allowing you to push call data to Smart Conversation Analysis (SCA) with a single click. Scenario 2: Integrates with a self-managed call center system, where each generated recording is pushed to SCA for analysis.
Operation description
Workflow
Call the API to upload audio for quality inspection => Convert the audio file to text => Separate the text into roles (agent and customer) based on the specified track splitting method => Analyze the text by using quality inspection rules => Complete the quality inspection.
Task execution efficiency
The execution speed of a task depends on the speed of converting the audio file to text. Ideally, a 5-minute audio file can be transcribed within 2 minutes. However, if the file transcription service has a large queue, a waiting time is required. Generally, the transcription is completed within 6 hours, except when a large amount of data is uploaded at a time (more than 500 hours of audio uploaded within half an hour). After the transcription is completed, the quality inspection analysis is performed in milliseconds.
Requirements for audio file URLs
Supports single-track or dual-track audio files in WAV or MP3 format. The file size must be less than 512 MB.
The URL must be accessible over HTTP. Committing local files is not supported. The access permissions of the audio file must be public.
The URL must contain only a domain name, not an IP address. The URL cannot contain spaces. Avoid using Chinese characters in the URL.
After the audio is converted to text, the system deletes the downloaded audio file and does not retain a copy.
If your audio URL has an expiration time, for example, the audio is stored in Alibaba Cloud OSS and an expiration time is specified when the URL is generated, we recommend that you set the expiration time to at least 12 hours, or preferably set the expiration time in Settings to 24 hours if conditions permit. This is because file transcription takes time and may occasionally be queued. If the queue is long, the audio is downloaded only when the transcription starts. A longer expiration time prevents the URL from expiring before the audio is downloaded.
After the quality inspection analysis is completed, the URL you provided is still used to play the audio when you review the file in the console. Therefore, you must ensure that the URL remains active for a long time. Otherwise, the audio cannot be played.
Role separation
After the audio 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. Therefore, you must separate the roles based on specific rules. The accuracy of role separation is crucial because the rules used for quality inspection analysis often have role restrictions (that is, a rule only checks the agent or the customer). Incorrect role separation greatly affects the accuracy of the quality inspection results.
Audio files are generally divided into single-track (mono) and dual-track (dual-channel/stereo) types:
Single-track audio: The voices of the agent and the customer are stored on a single track. After the audio file is converted to text, the system uses a built-in algorithm to separate the conversation into two roles. You can set a list of keywords that the agent may say. The system analyzes the transcribed text sentence by sentence from top to bottom. If a sentence hits a keyword, the role of the 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 uncontrollability of the conversation content (for example, the two roles may interrupt each other or speak at the same time), role separation for single-track audio cannot be 100% accurate. We strongly recommend that you save audio files as dual-track audio.
Dual-track audio: The voices of the agent and the customer are stored on two separate tracks. Even if the conversation overlaps, the system can accurately distinguish the roles when the audio is converted to text. You can specify the agent and the customer by using the serviceChannel and clientChannel request parameters.
Obtain quality inspection analysis results
Because audio file recognition is not real-time, you must obtain the quality inspection analysis results asynchronously. You can use one of the following three methods to obtain the results:
Message notification: For details, see MSMQ. After you receive a message, call the GetResult operation to obtain the detailed results. (Recommended)
Callback: Specify callbackUrl in the request parameters. After the node is completed, the system initiates a callback. After you receive the callback, call the GetResult operation to obtain the detailed results.
Polling: The operation returns a node ID (taskId). You can use the taskId to poll the
getResultoperation to asynchronously obtain the results and check whether thestatusresponse parameter indicates completion. We recommend that you do not set the polling interval too short. Normally, the analysis is completed within a few minutes. We recommend that you set the polling interval to 30 seconds or more. (Not recommended)
Try it now
Test
RAM authorization
|
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, see the following information. |
{“callList”:“xxxxx”} |
| BaseMeAgentId |
integer |
No |
The workspace ID. This parameter is used to select a specific workspace in multi-workspace scenarios. Default value: the default workspace. |
123456 |
Request parameters and JSON string information
| Property | Value type | Required | Description |
| callList | List | Yes | The collection of audio files. You can upload multiple audio files at a time. For details, see the Description of jsonStr.callList properties section below. |
| autoSplit | Integer | No | Specifies whether to automatically split tracks. This parameter applies to single-track audio in most cases. Valid values: - 1: Automatically splits tracks. This value indicates that the uploaded audio is single-track. Automatic track splitting requires additional processing time. - 0: Does not split tracks. If the audio is dual-track, you must set this parameter to 0. Default value: 1. |
| enableAutoSplitByLLM | Boolean | No | Specifies the parameter settings for the LLM-based automatic role separation feature. If you set this parameter to true, the LLM-based intelligent role separation feature is used for the audio file. Default value: false. |
| recognizeRoleDataSetId | Long | No | The dataset ID. You can use an existing dataset. When a dataset is created, the role separation Settings are configured (you can view the Speaker role configuration in the dataset creation feature). If you specify a dataset ID, the uploaded files reuse the role separation rules of the dataset. This parameter applies to single-track audio. |
| serviceChannelKeywords | List | No | The list of keywords that the agent may say. This parameter applies to single-track audio in most cases. Make sure that the keywords are highly distinctive. The system analyzes the transcribed text sentence by sentence from top to bottom. If a sentence hits a keyword, the role of the sentence is determined to be the agent, and the other role is the customer. If both recognizeRoleDataSetId and serviceChannelKeywords are specified, recognizeRoleDataSetId takes precedence. If neither is specified, the system uses the built-in track splitting rules as a fallback. |
| serviceChannel | Integer | No | The track number of the agent role. This parameter applies to dual-track audio. Valid values: 0 and 1. Default value: 0, which indicates that Track 0 is the agent. Tracks are usually numbered starting from 0. For two tracks, the numbers are 0 and 1. You must confirm whether Track 0 is the agent or the customer. If you use this parameter, you must also pass the autoSplit parameter and set it to 0. Ignore this parameter for single-track files. |
| clientChannel | Integer | No | The track number of the customer role. This parameter applies to dual-track audio. Valid values: 0 and 1. Default value: 1, which indicates that Track 1 is the customer. Tracks are usually numbered starting from 0. For two tracks, the numbers are 0 and 1. You must confirm whether Track 0 is the agent or the customer. If you use this parameter, you must also pass the autoSplit parameter and set it to 0. Ignore this parameter for single-track files. |
| sampleRate | Integer | No | The sampling rate of the audio file. Valid values: 8 (8000 Hz) and 16 (16000 Hz). Default value: 8. You must correctly specify the sampling rate of the audio file. An incorrect sampling rate causes transcription errors. Generally, the sampling rate of audio generated by a call center is 8000 Hz. |
| callbackUrl | String | No | The callback URL. If this parameter is not specified, no callback is initiated. Ensure public access to the callback URL. IP addresses are not supported. A callback is initiated after the audio analysis is completed. For details, see the Callback parameter description section below. |
Description of jsonStr.callList properties:
| Property | Value type | Required | Description |
| voiceFileUrl | String | Yes | The audio file URL. For specific requirements, see the Requirements for audio file URLs section in the API description. |
| fileName | String | No | The name of the audio file, such as audio.wav. Although this parameter is not required, we recommend that you provide it for statistical purposes. If this parameter is not provided, the file name is obtained from voiceFileUrl. For example, if the URL is http://www.aliyun.com/audio.wav, the parsed file name is audio.wav. |
| autoSplit | Integer | No | See metric description of the upper-level object parameter. If this parameter is empty, the value of the upper-level object is used. |
| recognizeRoleDataSetId | Long | No | See metric description of the upper-level object parameter. If this parameter is empty, the value of the upper-level object is used. |
| serviceChannel | Integer | No | See metric description of the upper-level object parameter. If this parameter is empty, the value of the upper-level object is used. |
| clientChannel | Integer | Yes | See metric description of the upper-level object parameter. If this parameter is empty, the value of the upper-level object is used. |
| sampleRate | Integer | No | See metric description of the upper-level object parameter. If this parameter is empty, the value of the upper-level object is used. |
| callStartTime | Long | No | The time when the recording occurred. The value is a millisecond timestamp, which is the number of milliseconds that have elapsed since 00:00:00 UTC on January 1, 1970 (for example, 1584535485856). If this parameter is not specified, the current time is used. |
| customerServiceId | Long | No | The agent ID. You can obtain the ID from the Personnel Management page in the console (Basic Settings > Personnel Management). If you correctly enter the agent ID, the agent can view the associated audio files when logging on to the console. |
| customerServiceName | String | No | The name of the agent. |
| skillGroupId | String | No | The skill group ID. |
| skillGroupName | String | No | The skill group name. |
| callType | Integer | No | The call type. Valid values: - 1: Outbound call. - 3: Inbound call. |
| callee | String | No | The called number. For an outbound call, this is the customer's number. For an inbound call, this is the agent's number. |
| caller | String | No | The calling number. For an outbound call, this is the agent's number. For an inbound call, this is the customer's number. |
| callId | String | No | The call ID. This can be the call ID in the call center system or another ID that identifies the call. |
| business | String | No | The business line name. This is custom data used for classified statistics. |
| callUuid | String | No | The globally unique identifier, used for idempotence (deduplication). If this field is passed, the system checks whether the same callUuid exists in the data uploaded within the last two hours. If it exists, the current upload request is rejected. |
| sessionGroupId | String | No | The session group ID. Generally, a session between the same agent and the same customer is called a session group. After you pass the session group ID, you can view the quality inspection results at the session group level on the session group result page. (Only applicable to the new version of Smart Conversation Analysis) |
| customerId | String | No | The customer ID. (Only applicable to the new version of Smart Conversation Analysis) |
| customerName | String | No | The customer name. (Only applicable to the new version of Smart Conversation Analysis) |
| schemeTaskConfigId | String | No | The manually specified quality inspection task ID. If you manually specify this ID, the specified quality inspection task is used for quality inspection. (Only applicable to the new version of Smart Conversation Analysis) |
| remark1 | String | No | Custom data 1. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark2 | String | No | Custom data 2. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark3 | String | No | Custom data 3. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark4 | String | No | Custom data 4. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark5 | Long | No | Custom data 5. You can store custom fields related to your business. The format is a signed long integer. |
| remark6 | String | No | Custom data 6. You can store custom fields related to your business. Maximum length: 1024 characters. |
| remark7 | String | No | Custom data 7. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark8 | String | No | Custom data 8. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark9 | String | No | Custom data 9. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark10 | String | No | Custom data 10. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark11 | String | No | Custom data 11. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark12 | String | No | Custom data 12. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark13 | String | No | Custom data 13. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark14 | Long | No | Custom data 14. You can store custom fields related to your business. The format is a signed long integer. |
| remark15 | Long | No | Custom data 15. You can store custom fields related to your business. The format is a signed long integer. |
| remark16 | String | No | Custom data 16. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark17 | String | No | Custom data 17. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark18 | String | No | Custom data 18. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark19 | String | No | Custom data 19. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark20 | String | No | Custom data 20. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark21 | String | No | Custom data 21. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark22 | String | No | Custom data 22. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark23 | String | No | Custom data 23. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark24 | String | No | Custom data 24. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark25 | String | No | Custom data 25. You can store custom fields related to your business. Maximum length: 64 characters. |
| jsonParamStr | String | No | Additional custom fields. The format is a JSON string. The key is the field name, and the value is the field content. Example: {"Customer level":3,"Channel":"Official website"}. |
Callback parameter description
Assume that the callback URL passed by the invoker is http://aliyun.com/callback. The complete URL during the callback is http://aliyun.com/callback?taskId=xxx×tamp=xxx&aliUid=xxx&signature=xxx&event=xxx, where:
taskId: the node ID.
timestamp: the UNIX timestamp when the invoke occurs, in milliseconds.
aliUid: the UID of the Alibaba Cloud account of the invoker.
signature: the signature, which the invoker can use to determine whether the request is from Alibaba Cloud. Calculation method: Perform MD5 and Base64 encryption on
taskId=xxx×tamp=xxx&aliUid=xxx. Note the order. After the invoker receives the callback, the invoker can obtain taskId and timestamp from the callback URL, and aliUid is the Alibaba Cloud account ID. The invoker calculates the signature and compares it with the signature in the URL to check whether they are consistent. For details, see the following Java code example.event: the event name, which the invoker can use to determine the event that triggers the callback. Valid value: TaskComplete, which indicates the callback when the node is completed.
public static void signature() {
long timestamp = System.currentTimeMillis().
String taskId = "xxx".
String aliUid = "xxx".
// Perform MD5 and Base64 encryption on taskId=xxx×tamp=xxx&aliUid=xxx and put the result in the signature field.
String signature.
try {
signature = URLEncoder.encode(md5Base64("taskId=" + taskId + "×tamp=" + timestamp + "&aliUid=" + aliUid), "utf-8").
System.out.println(signature).
} catch (Exception e) {
e.printStackTrace().
}
}
public static String md5Base64(String str) throws NoSuchAlgorithmException {
// The 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":[
"Study abroad",
"Agent"
],
"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":"Pre-sales skill group",
"callType":1,
"callee":188888****,
"caller":"0102323***",
"callId":23456457**,
"business":"Pre-sales group 1",
"remark1":"March 8 promotion"
}
]
}
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" +
" \"Study abroad\",\n" +
" \"Agent\"\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\":\"Pre-sales skill group\",\n" +
" \"callType\":1,\n" +
" \"callee\":188888****,\n" +
" \"caller\":\"0102323***\",\n" +
" \"callId\":23456457**,\n" +
" \"business\":\"Pre-sales group 1\",\n" +
" \"remark1\":\"March 8 promotion\"\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 result. |
||
| Code |
string |
The result code. A value of 200 indicates success. Any other value indicates failure. You can use this field to determine the cause of the failure. |
200 |
| Message |
string |
The error message. If the request fails, this field displays the error details. If the request is successful, the value is successful. |
successful |
| Data |
string |
The task ID. This ID is used when you obtain the task result. |
76DB5D8C-5BD9-42A7-B527-5AF3A5*** |
| RequestId |
string |
The request ID. This ID uniquely identifies the request. |
76DB5D8C-5BD9-42A7-B527-5AF3A5F8*** |
| Success |
boolean |
Indicates whether the request is successful. You can use this field to determine whether the request is successful. A value of true indicates success. A value of false or null indicates failure. |
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.