Feature Description
Creating a Text To Speech (TTS) Template
Authorization Description
When using a sub-account, you need to add the ci:CreateMediaTemplate permission to the action in the authorization policy. For all supported operation APIs of Cloud Infinite (CI), see CI action. Service Activation
To use this feature, you need to bind a bucket in advance and enable Cloud Infinite service. To use this feature, you need to enable Smart Audio Service in advance via the console or API. Note:
Note: After binding Cloud Infinite, if you manually perform bucket unbind, you will not be able to continue using this function.
Use Limits
When using this API, please confirm the related use limits. For details, see Use Limits. Request
Request sample
POST /template HTTP/1.1
Host: <BucketName-APPID>.ci.<Region>.myqcloud.com
Date: <GMT Date>
Authorization: <Auth String>
Content-Length: <length>
Content-Type: application/xml
<body>
Request header
Request body
The following figure shows the request bodies required for implementing this request operation.
<Request>
<Tag>Tts</Tag>
<Name>TemplateName</Name>
<Mode>Sync</Mode>
<Codec>pcm</Codec>
<VoiceType>aixiaoxing</VoiceType>
<Volume>2</Volume>
<Speed>200</Speed>
<Emotion>arousal</Emotion>
</Request>
The detailed data is described as follows:
|
Request | None. | Container for saving requests | Container | Yes |
Container type Request
data description as follows: |
Tag | Request | Template type: Tts | String | Yes |
Name | Request | Template name, supporting only Chinese, English, digits, _, -, and *, with a length not exceeding 64. | String | Yes |
Mode | Request | Processing mode, valid values include: Async (default value): async synthesis Sync: sync synthesis | String | No |
Codec | Request | Audio format, valid values include: wav mp3 pcm When Mode = Sync, the default value is wav; when Mode = Async, the default value is pcm. | String | No |
VoiceType | Request | Voice type, parameter values and limitations are listed in the table below. Default value is ruxue. | String | No |
Volume | Request | Volume, with a range of [-10, 10]. Default value is 0. | String | No |
Speed | Request | Speaking rate, with a range of [50, 200]. Default value is 100. | String | No |
Emotion | Request | Emotion. Different timbres support different emotions. See the table below. No default value. | String | No |
Supported Timbre
|
Ru Xue | ruxue | Supported | Supported |
Xiao Nan | aixiaonan | Not supported | Supported |
Aixiaoxing | aixiaoxing | Supported | Supported |
Aixiaocheng | aixiaocheng | Supported | Supported |
Aixiaoxue | aixiaoxue | Supported | Supported |
Aixiaoyu | aixiaolu | Supported | Supported |
Xiao Dong | aixiaodong | Supported | Supported |
Xiao Liao | aixiaoliao | Not supported | Supported |
Xiao Qian | aixiaoqian | Supported | Supported |
Aixiaoyang | aixiaoyang | Supported | Supported |
Alice | alice | Supported | Supported |
Timbre Description
|
Ru Xue | ruxue | Standard female voice | Common scenarios | Chinese and Chinese-English mix | Standard Edition |
Xiao Nan | aixiaonan | sweet female voice | Common scenarios/Social scenario | Chinese and Chinese-English mix | Premium Edition |
Aixiaoxing | aixiaoxing | energetic male voice | Common scenarios Commentate scenarios | Chinese and Chinese-English mix | Premium Edition |
Aixiaocheng | aixiaocheng | Standard male voice | Common scenarios | Chinese and Chinese-English mix | Standard Edition |
Aixiaoxue | aixiaoxue | Standard female voice | Create and Bind Policy Query Instance Reset Instance Access Password | Chinese and Chinese-English mix | Standard Edition |
Aixiaoyu | aixiaolu | read female voice | General/Audiobook Scenes | Chinese and Chinese-English mix | Standard Edition |
Xiao Dong | aixiaodong | news male voice | Common news broadcast scenarios | Chinese and Chinese-English mix | Standard Edition |
Xiao Liao | aixiaoliao | emotional female voice | Common scenarios/Social scenario | Chinese and Chinese-English mix | Premium Edition |
Xiao Qian | aixiaoqian | energetic female voice | Common scenarios/Social scenario | Chinese and Chinese-English mix | Premium Edition |
Aixiaoyang | aixiaoyang | Broadcast male voice | Common news broadcast scenarios | Chinese and Chinese-English mix | Standard Edition |
Alice | alice | English Female Voice | Common scenarios | English | Standard Edition |
Timbre Supports Emotion Description
|
Aixiaoxing | aixiaoxing | neutral arousal |
Aixiaocheng | aixiaocheng | neutral newscast |
Aixiaoxue | aixiaoxue | neutral newscast customer service |
Aixiaoyu | aixiaolu | neutral story customer service |
Xiao Dong | aixiaodong | neutral newscast |
Aixiaoyang | aixiaoyang | neutral newscast |
Response
Response Headers
Response Body
The response body is returned as application/xml. An example including the complete node data is shown below:
<Response>
<RequestId>NjQ0NGNlNDZfMThhYTk0MGFfY*********</RequestId>
<Template>
<Tag>Tts</Tag>
<TemplateId>t1460606b9752148c4ab182f55163ba7cd</TemplateId>
<Name>TemplateName</Name>
<BucketId>test-1234567890</BucketId>
<Category>Custom</Category>
<TtsTpl>
<Mode>Sync</Mode>
<Codec>pcm</Codec>
<VoiceType>aixiaoxing</VoiceType>
<Volume>2</Volume>
<Speed>200</Speed>
<Emotion>arousal</Emotion>
</TtsTpl>
<CreateTime>2020-08-05T11:35:24+0800</CreateTime>
<UpdateTime>2020-08-31T16:15:20+0800</UpdateTime>
</Template>
</Response>
The data are as follows:
|
Response | None. | Container for saving results | Container |
Container node Response
content: |
Template | Response | Container for saving template details | Container |
RequestId | Response | unique request ID | String |
Container node Template
content: |
TemplateId | Response.Template | template ID | String |
Name | Response.Template | Template Name | String |
BucketId | Response.Template | template's bucket | String |
Category | Response.Template | template property, Custom or Official | String |
Tag | Response.Template | Template type: Tts | String |
UpdateTime | Response.Template | Update time | String |
CreateTime | Response.Template | Creation time | String |
TtsTpl | Response.Template | Detailed template parameters | Container |
Container node TtsTpl content:
|
Mode | Response.Template.TtsTpl | |
Codec | Response.Template.TtsTpl | |
VoiceType | Response.Template.TtsTpl | |
Volume | Response.Template.TtsTpl | |
Speed | Response.Template.TtsTpl | |
Emotion | Response.Template.TtsTpl | |
Error Code
This request returns common error responses and error codes. For more information, see Error Codes. Practical Case
Request
POST /template HTTP/1.1
Authorization: q-sign-algorithm=sha1&q-ak=************************************&q-sign-time=1497530202;1497610202&q-key-time=1497530202;1497610202&q-header-list=&q-url-param-list=&q-signature=****************************************
Host: test-1234567890.ci.ap-beijing.myqcloud.com
Content-Length: 1666
Content-Type: application/xml
<Request>
<Tag>Tts</Tag>
<Name>TemplateName</Name>
<Mode>Sync</Mode>
<Codec>pcm</Codec>
<VoiceType>ruxue</VoiceType>
<Volume>2</Volume>
<Speed>200</Speed>
</Request>
Response
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 100
Connection: keep-alive
Date: Thu, 14 Jul 2022 12:37:29 GMT
Server: tencent-ci
x-ci-request-id: NTk0MjdmODlfMjQ4OGY3XzYzYzhf****
<Response>
<RequestId>NjQ0NGNlNDZfMThhYTk0MGFfY*********</RequestId>
<Template>
<Tag>Tts</Tag>
<TemplateId>t1460606b9752148c4ab182f55163ba7cd</TemplateId>
<Name>TemplateName</Name>
<BucketId>test-1234567890</BucketId>
<Category>Custom</Category>
<TtsTpl>
<Mode>Sync</Mode>
<Codec>pcm</Codec>
<VoiceType>ruxue</VoiceType>
<Volume>2</Volume>
<Speed>200</Speed>
</TtsTpl>
<CreateTime>2020-08-05T11:35:24+0800</CreateTime>
<UpdateTime>2020-08-31T16:15:20+0800</UpdateTime>
</Template>
</Response>