Sync Synthesis
Update:
Text To Speech
Product Overview
- Convert text into natural speech through LiveData artificial intelligence technology
Apply for services
Synthesis API uses a complete flow and self-application model. You may sign up on the LiveData’s official website (https://www.ilivedata.com/), and then create an application on console. A pid and a service key will be sent to you.
You can also activate other services on the Management Console - Overview Page.
Access Method
Service Endpoint
https://tts.ilivedata.com/api/v1/speech/synthesis
HTTP Request headers
Header
value
Description
Content-Type
application/json;charset=UTF-8
Request body type
Accept
application/json;charset=UTF-8
Respone body type
X-AppId
demo:81900001
Application ID or Project ID
X-TimeStamp
Request time in UTC format
For example: 2010-01-31T23:59:59Z. (for more information, go tohttp://www.w3.org/TR/xmlschema-2/#dateTime).
Authorization
Signature Token
Check Authentication section below
Request Method:POST
Request Body
Field Name
Optional
Type
Description
text
Required
String
text content,length range:[1,500]
language
Optional
String
Text content language. If not, the language will be automatically detected.
voice
可选
VoiceSetting
Synthetic voice related configuration. When the parameter is empty, the system default sound corresponding to the language is used.
Output
Optional
Output
Output config
VoiceSetting:
Field Name
Optional
Type
Description
name
Optional
String
Optional sound names provided on the cloud (contact relevant staff for specific sound libraries, custom sounds are not yet available)
audio
Optional
String
Target sound audio file address (currently only supports wav format)
OutputSetting:
Field Name
Optional
Type
Description
format
Optional
String
Output audio format, candidate is:pcm、wav、mp3,default is: wav
Request Body
Request Sample
{
"text": "想让文字出来跳舞吗?我们的语音合成服务就像魔法一样,把无声的字句变成有趣的声音冒险!",
"language": "zh-CN",
"output": {
"gender": 0,
"format": "mp3"
}
}
Request sign:
When the user requests the speech synthesis API, he or she can use the appId and secretKey to sign the request. When the API receives the request with signature information, it will use the same algorithm to verify the signature. If the signature is found to be inconsistent, the API will return 401 to the user.
If the API verification signatures are consistent and the user corresponding to the appId has the permission to operate the requested resource, the request is successful, otherwise the API returns 401.
Send signature via HTTP request header
Method: Add a header named Authorization in the request, whose value is the signature value. For example:
Authorization: ****
Signature calculation method
- Canonicalized Query String:
Convert the request body JSON string to a hexadecimal string (not Base64) by doing sha256 encoding with UTF-8 character encoding.
CanonicalizedQueryString = hex(sha256(jsonBody))
-
Constructs the signed string StringToSign ("\n" stands for ASCII newline character):
StringToSign = HTTPMethod + "\n" +
HostHeaderInLowercase + "\n" +
HTTPRequestURI + "\n" +
CanonicalizedQueryString <get from previous> + "\n" +
"X-AppId:" + SAME_APPID_IN_HEADER + "\n" +
"X-TimeStamp:" + SAME_TIMESTAMP_IN_HEADER
The HTTP RequestURI is the absolute path to the request URI, without the request string. If the HTTPRequestURI is empty, also keep a forward slash (/)
The hash-based message authentication code (HMAC) is created using the HMAC-SHA256 protocol and the signature is calculated.
-
StringToSign as the signature string, secretKey as the secret key and SHA256 as the hash algorithm.
For more information about HMAC, see: https://tools.ietf.org/html/rfc2104.
-
Converting the results of the previous step to a BASE64 string
-
Put the BASE64 string into the Authorization of HTTP request Header
Example of signature
Below is an example of appId & secretKey & video.
appId=81900001
secrectKey=****
Below is an example of request type.
{"text":"想让文字出来跳舞吗?我们的文本转语音服务就像魔法一样,把无声的字句变成有趣的声音冒险!.","language":"zh-CN","output":{"gender":0,"format":"mp3"}}
Generate CanonicalizedQueryString
3ff89070a25e4091c94f03ad3cf014d712aaf9e069ef654b0e7e58b2b4550e31
Generate StringToSign
POST
tts.ilivedata.com
/api/v1/speech/synthesis
3ff89070a25e4091c94f03ad3cf014d712aaf9e069ef654b0e7e58b2b4550e31
X-AppId:81900001
X-TimeStamp:2024-07-01T07:59:59Z
Signatures from HMAC calculations
*****
HTTP Response
Content-Type: application/json;charset=UTF-8
The result is in JSON format, please refer to the following example.
- Example of HTTP response:
Description of returning json field:
Field Name
Type
Description
errorCode
Number
Error code: 0 means success
errorMessage
String
Error message
textSpam
json object
Resut message
warning
Boolean
Customize the alarm information of advertising words, and configure it when adding a blacklist on the console
taskId
String
Unique identifier to distinguish different calls
startTime
Number
Timestamp, representing the detection text call time
endTime
Number
Timestamp, representing the return time of the detected text result
Field Name
Type
Description
errorCode
Number
0,success
errorMessage
String
Prompt Message
data
ResponseData
Response Data
ResponseData
Field Name
Type
Description
taskId
String
Unique task ID
url
String
download url for output file
duration
Float
duration of output file
language
String
text language
Response Sample
Sample Response
{
"errorCode": 0,
"errorMessage": "Success.",
"data": {
"taskId": "ap_xxxxxxxxxxx",
"url": "https://xxx.mp3",
"duration": 12.0,
"language": "zh-CN"
}
}
Text To Speech
Product Overview
- Convert text into natural speech through LiveData artificial intelligence technology
Apply for services
Synthesis API uses a complete flow and self-application model. You may sign up on the LiveData’s official website (https://www.ilivedata.com/), and then create an application on console. A pid and a service key will be sent to you.
You can also activate other services on the Management Console - Overview Page.
Access Method
Service Endpoint
https://tts.ilivedata.com/api/v1/speech/synthesis
HTTP Request headers
Header | value | Description |
---|---|---|
Content-Type | application/json;charset=UTF-8 | Request body type |
Accept | application/json;charset=UTF-8 | Respone body type |
X-AppId | demo:81900001 | Application ID or Project ID |
X-TimeStamp | Request time in UTC format | For example: 2010-01-31T23:59:59Z. (for more information, go tohttp://www.w3.org/TR/xmlschema-2/#dateTime). |
Authorization | Signature Token | Check Authentication section below |
Request Method:POST
Request Body
Field Name | Optional | Type | Description |
---|---|---|---|
text | Required | String | text content,length range:[1,500] |
language | Optional | String | Text content language. If not, the language will be automatically detected. |
voice | 可选 | VoiceSetting | Synthetic voice related configuration. When the parameter is empty, the system default sound corresponding to the language is used. |
Output | Optional | Output | Output config |
VoiceSetting:
Field Name | Optional | Type | Description |
---|---|---|---|
name | Optional | String | Optional sound names provided on the cloud (contact relevant staff for specific sound libraries, custom sounds are not yet available) |
audio | Optional | String | Target sound audio file address (currently only supports wav format) |
OutputSetting:
Field Name | Optional | Type | Description |
---|---|---|---|
format | Optional | String | Output audio format, candidate is:pcm、wav、mp3,default is: wav |
Request Body
Request Sample
{
"text": "想让文字出来跳舞吗?我们的语音合成服务就像魔法一样,把无声的字句变成有趣的声音冒险!",
"language": "zh-CN",
"output": {
"gender": 0,
"format": "mp3"
}
}
Request sign:
When the user requests the speech synthesis API, he or she can use the appId and secretKey to sign the request. When the API receives the request with signature information, it will use the same algorithm to verify the signature. If the signature is found to be inconsistent, the API will return 401 to the user.
If the API verification signatures are consistent and the user corresponding to the appId has the permission to operate the requested resource, the request is successful, otherwise the API returns 401.
Send signature via HTTP request header
Method: Add a header named Authorization in the request, whose value is the signature value. For example:
Authorization: ****
Signature calculation method
- Canonicalized Query String:
Convert the request body JSON string to a hexadecimal string (not Base64) by doing sha256 encoding with UTF-8 character encoding.
CanonicalizedQueryString = hex(sha256(jsonBody))
-
Constructs the signed string StringToSign ("\n" stands for ASCII newline character):
StringToSign = HTTPMethod + "\n" + HostHeaderInLowercase + "\n" + HTTPRequestURI + "\n" + CanonicalizedQueryString <get from previous> + "\n" + "X-AppId:" + SAME_APPID_IN_HEADER + "\n" + "X-TimeStamp:" + SAME_TIMESTAMP_IN_HEADER
The HTTP RequestURI is the absolute path to the request URI, without the request string. If the HTTPRequestURI is empty, also keep a forward slash (/)
The hash-based message authentication code (HMAC) is created using the HMAC-SHA256 protocol and the signature is calculated.
-
StringToSign as the signature string, secretKey as the secret key and SHA256 as the hash algorithm.
For more information about HMAC, see: https://tools.ietf.org/html/rfc2104.
-
Converting the results of the previous step to a BASE64 string
-
Put the BASE64 string into the Authorization of HTTP request Header
Example of signature
Below is an example of appId & secretKey & video.
appId=81900001
secrectKey=****
Below is an example of request type.
{"text":"想让文字出来跳舞吗?我们的文本转语音服务就像魔法一样,把无声的字句变成有趣的声音冒险!.","language":"zh-CN","output":{"gender":0,"format":"mp3"}}
Generate CanonicalizedQueryString
3ff89070a25e4091c94f03ad3cf014d712aaf9e069ef654b0e7e58b2b4550e31
Generate StringToSign
POST
tts.ilivedata.com
/api/v1/speech/synthesis
3ff89070a25e4091c94f03ad3cf014d712aaf9e069ef654b0e7e58b2b4550e31
X-AppId:81900001
X-TimeStamp:2024-07-01T07:59:59Z
Signatures from HMAC calculations
*****
HTTP Response
Content-Type: application/json;charset=UTF-8
The result is in JSON format, please refer to the following example.
- Example of HTTP response:
Description of returning json field:
Field Name | Type | Description |
---|---|---|
errorCode | Number | Error code: 0 means success |
errorMessage | String | Error message |
textSpam | json object | Resut message |
warning | Boolean | Customize the alarm information of advertising words, and configure it when adding a blacklist on the console |
taskId | String | Unique identifier to distinguish different calls |
startTime | Number | Timestamp, representing the detection text call time |
endTime | Number | Timestamp, representing the return time of the detected text result |
Field Name | Type | Description |
---|---|---|
errorCode | Number | 0,success |
errorMessage | String | Prompt Message |
data | ResponseData | Response Data |
ResponseData
Field Name | Type | Description |
---|---|---|
taskId | String | Unique task ID |
url | String | download url for output file |
duration | Float | duration of output file |
language | String | text language |
Response Sample
Sample Response
{
"errorCode": 0,
"errorMessage": "Success.",
"data": {
"taskId": "ap_xxxxxxxxxxx",
"url": "https://xxx.mp3",
"duration": 12.0,
"language": "zh-CN"
}
}