Help Center/ Cognitive Engagement Center/ API Reference/ Call Center Configuration Interface Reference/ IVR Flow Management/ Uploading a TTS Template for Voice Notifications (createVoiceTemplate)
Updated on 2023-09-27 GMT+08:00

Uploading a TTS Template for Voice Notifications (createVoiceTemplate)

Scenario

Upload a TTS template for voice notifications.

Method

POST

URI

https://Domain name/apiaccess/rest/cc-management/v1/createVoiceTemplate (For example, the domain name is service.besclouds.com.)

Request Description

Table 1 Request header parameters

No.

Parameter

Type

Mandatory or Not

Description

1

Authorization

String

Yes

Authentication field. The format is Bearer {Value of AccessToken returned by the tokenByAkSk interface}. (A space is required after Bearer.)

2

X-APP-Key

String

No

App key field, which is the user ID. Contact the operation personnel to obtain the app key.

Table 2 Request body parameters

No.

Parameter

Type

Mandatory or Not

Description

1

requestBody

Object

No

-

1.1

name

String

Yes

Name of the TTS template file. The value can contain Chinese characters, digits, and uppercase and lowercase letters. The value contains a maximum of 50 characters.

1.2

scene

String

No

Application scenario.

The option is 3, indicating voice notification.

1.3

speed

Number

No

Speed of the converted voice. The value ranges from –200 to 500. If this parameter is left blank, the default value 0 is used.

1.4

volume

Number

No

Volume of the converted voice. The value ranges from 0 to 100. If this parameter is left blank, the default value 50 is used.

1.5

voicename

String

No

Timbre of the converted voice. The options are as follows:

  • cn_kefuman_common: graceful
  • cn_chengshuxing_common: mature
  • cn_roumeiqian_common: soft
  • cn_ziranzhen_common: natural
  • cn_tianmeiru_common: sweet

If this parameter is left blank, the default value cn_kefuman_common is used.

1.6

voicecontent

Object

Yes

Text content to be converted to voice.

1.6.1

textcontent

String

Yes

Text content. The value contains a maximum of 500 bytes.

The template content consists of fixed texts and variables. The template uses the UTF-8 encoding format. A Chinese character or symbol occupies three bytes. A letter, digit, or English symbol occupies one byte.

  • The template content cannot start with a variable.
  • The template content can contain a maximum of 500 bytes.
  • A variable can contain a maximum of 32 bytes. (If a variable contains more than 32 bytes, you are advised to split it into multiple variables.)

    The following variable formats are supported:

    • ${TXT_Digit}: String. Digit indicates the maximum length of the string. For example, ${TXT_9} indicates a string of a maximum of nine characters.
    • ${NUM_Digit}: Number. Digit indicates the maximum number of digits in the number. For example, ${NUM_6} indicates a number of a maximum of six digits.
    • ${DATE}: Date, in the format of YYYY/MM/DD. YYYY indicates the year, MM indicates the month, and DD indicates the day. An example is 2022/07/16.
    • ${TIME}: Time, in the format of HH:MM or HH:MM:SS. HH indicates the hour, MM indicates the minute, and SS indicates the second. Examples are 14:30 and 14:30:30.

Template examples:

  • Example 1: Dear ${TXT_8}, your initial password is ${NUM_6}.
  • Example 2: Please pick up your express delivery before ${TIME} on ${DATE}.
    NOTE:

    ${TIME} and ${DATE} must be separated by " on ".

1.6.2

language

String

Yes

Language.

  • zh_CN: Chinese
  • en_US: English
  • pt_BR: Portuguese
  • th_TH: Thai

1.7

callBackUrl

String

No

Callback URL. The system returns the review result to this URL.

The callback URL indicates the API defined by the customer for receiving the system review result. For details about the request and response parameters, see Table 3.

The callback URL must have been added to the IVR voice upload callback URL trustlist by the system administrator.

Table 3 Callback URL parameters

No.

Parameter

Type

Mandatory or Not

Description

Request parameters

1.7.1

fileUrl

String

Yes

Address of the file to be reviewed. The value is a full file address, including the file name extension.

1.7.2

fileId

String

Yes

ID of the file to be reviewed. For details about how to set this parameter, see the description of the templateId parameter in Table 4.

1.7.3

status

String

Yes

  • File review status. The options are as follows:
    • 2: approved
    • 3: rejected

1.7.4

comment

String

No

Review status remarks.

Response parameter

1.7.5

returnCode

String

Yes

Response code. The options are as follows:
  • 0: The review result is received successfully.
  • Others: The review result fails to be received.
    NOTE:

    If the review result fails to be received, the callback API is repeatedly invoked to return the file review result. After six times, the file review result is no longer returned.

Response Description

  • Response code: 200
Table 4 Response parameters

No.

Parameter

Type

Mandatory or Not

Description

1

schema

Object

Yes

-

1.1

returnCode

String

Yes

Result code. 0: success; other values: failure.

1.2

description

String

Yes

Description.

1.3

templateId

String

No

Template ID.

  • Status code: 404

    The requested content is not found. Check the request path.

  • Status code: 500

    Business failure. Check the values of parameters in the request.

Error Codes

None

Example

Request header:

Content-Type:application/json
Authorization:Bearer XXXXXXXXXXXXXXXXXXXXXXX
X-APP-Key:XXXXXXXXXXXXXXXXXXXXXXX

Request parameters:

{
     "name":"ctest1",
     "scene":"3",
     "volume":0,
    "speed":50,
     "voicename":"cn_kefuman_cn",
     "callBackUrl" : "http://10.134.227.74:18133/upload",
     "voicecontent":{
             "language":"en_US",
             "textcontent":"test"
     }
 }

Response parameters:

{
   "returnCode": "0",
   "description": "The file is uploaded successfully.",
   "templateId": "1249756280719641601"
 }

Callback URL parameters:

//Request parameters
{
    "fileUrl": "Y:/IVR/147/voice/0/nPqV9vU3_1666706957559.wav",
    "fileId": "1323606152730207249",
    "status": "2",
    "comment": "approved"
}
//Response parameters
{
    "returnCode": "0"
}