Domain name for API request: tts.intl.tencentcloudapi.com.
This API is used to convert any text to speech, allowing your devices and applications to talk to users.
u200bTencent Cloud Text To Speech (TTS) can synthesize speech from text in real time for many use cases, such as audiobook and news apps, voice reminders on smart devices, quick synthesis of a celebrity's voice based on existing programs or certain voice records available on the internet, and personalized vehicle navigation systems.
It is free for use in beta.
It supports SSML. For syntax details, see SSML.
Default API request rate limit: 20 requests/sec.
The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.
Parameter Name | Required | Type | Description |
---|---|---|---|
Action | Yes | String | Common Params. The value used for this API: TextToVoice. |
Version | Yes | String | Common Params. The value used for this API: 2019-08-23. |
Region | Yes | String | Common Params. For more information, please see the list of regions supported by the product. |
Text | Yes | String | The source text for synthesizing speech, which is encoded in UTF-8. It can contain up to 150 Chinese characters (a full-width punctuation as a Chinese character) or 500 letters ( a half-width punctuation as a letter). |
SessionId | Yes | String | The SessionId of a request, which will be returned as-is. We recommend that you pass characters like uuid to prevent repetition. |
Volume | No | Float | Volume range: [0, 10], corresponding to 11 volume levels. 0 is the default value, indicating the normal volume. There is no mute option. |
Speed | No | Float | Speed range: [-2, 6], corresponding to different speeds |
ProjectId | No | Integer | Project ID, which defaults to 0 and can be customized. |
ModelType | No | Integer | Model type, with 1 for the default model. |
VoiceType | No | Integer | Standard voices Premium voices have higher fidelity and more natural-sounding quality than standard voices. For price details, see Purchase Guide. |
PrimaryLanguage | No | Integer | Primary language type: |
SampleRate | No | Integer | Audio sample rate: |
Codec | No | String | Format of returned audio. Valid values: WAV (default), MP3, and PCM. |
EnableSubtitle | No | Boolean | Whether to enable the timestamp feature. Default value: false . |
SegmentRate | No | Integer | The threshold of speech segmentation sensibility, which can be 0 (default), 1 , or 2 . A larger value indicates fewer segments, and the model tends to only segment sentences based on punctuation marks. We recommend you not change this parameter to avoid adverse effect on speech synthesis. |
Parameter Name | Type | Description |
---|---|---|
Audio | String | Base64-encoded WAV/MP3 audio data |
SessionId | String | The SessionId of a request |
Subtitles | Array of Subtitle | Timestamp information. If the timestamp feature is not enabled, an empty array will be returned. |
RequestId | String | The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem. |
POST / HTTP/1.1
Host: tts.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: TextToVoice
<common request parameters>
{
"Text": "你好",
"SessionId": "session-1234",
"Volume": 1,
"Speed": 1,
"ProjectId": 0,
"ModelType": 1,
"VoiceType": 1001,
"PrimaryLanguage": 1,
"SampleRate": 16000,
"Codec": "wav",
"EnableSubtitle": true
}
{
"Response": {
"Audio": "UklGRqRwAABXQVZFZm10IBAAAAABAAEAgD4AAAB9AAACABAAZGF0YYBwAAAA......AAAAA=",
"RequestId": "d91f1496-0514-4281-932e-15a022b67d16",
"SessionId": "session-1234",
"Subtitles": [
{
"BeginIndex": 0,
"BeginTime": 250,
"EndIndex": 1,
"EndTime": 430,
"Phoneme": "ni2",
"Text": "你"
},
{
"BeginIndex": 1,
"BeginTime": 430,
"EndIndex": 2,
"EndTime": 670,
"Phoneme": "hao3",
"Text": "好"
}
]
}
}
TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.
The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.
Error Code | Description |
---|---|
AuthFailure.InvalidAuthorization | Invalid authorization. |
InternalError.ErrorGetRoute | Invalid route. |
InternalError.ExceedMaxLimit | Traffic is throttled due to high load. |
InternalError.InternalError | Internal error. |
InternalError.NoResource | |
InvalidParameter.InvalidText | The request text contains invalid characters. |
InvalidParameterValue.AppId | Invalid AppId . See the description of AppId . |
InvalidParameterValue.AppIdNotRegistered | The APPID is not registered. Activate the service in the TTS console (https://console.tencentcloud.com/tts) first. |
InvalidParameterValue.Codec | Invalid Codec . See the description of Codec . |
InvalidParameterValue.ErrorCardinalFormat | The number part of the say-as tag of SSML is not a valid constant, which can only contain digits, ",", ".", and " " when the tag attribute is cardinal , currency , or address . |
InvalidParameterValue.InvalidText | The request text contains invalid characters, or it contains no valid characters. |
InvalidParameterValue.MissParameters | Parameter missing. |
InvalidParameterValue.ParticipleError | Error in text segmentation. |
InvalidParameterValue.PrimaryLanguage | Invalid PrimaryLanguage . See the description of PrimaryLanguage . |
InvalidParameterValue.SSMLInvalid | Invalid SSML tag. |
InvalidParameterValue.SampleRate | Invalid SampleRate . See the description of SampleRate . |
InvalidParameterValue.SessionId | Invalid SessionId . See the description of SessionId . |
InvalidParameterValue.Speed | Invalid Speed . See the description of Speed . |
InvalidParameterValue.Text | Text missing. |
InvalidParameterValue.TextEmpty | Empty text. |
InvalidParameterValue.TextNotUtf8 | The text is not encoded in UTF8. |
InvalidParameterValue.Type | Invalid Type . |
InvalidParameterValue.VoiceType | Invalid VoiceType . See the description of VoiceType . |
InvalidParameterValue.Volume | Invalid Volume . See the description of Volume . |
LimitExceeded.AccessLimit | The request frequency exceeds the limit. |
UnsupportedOperation | Unsupported operation. |
UnsupportedOperation.AccountArrears | Overdue payment exists. |
UnsupportedOperation.AuthorizationExpired | Authentication expired. |
UnsupportedOperation.AuthorizationFailed | Authentication failed. |
UnsupportedOperation.ForbiddenUse | Service prohibited. |
UnsupportedOperation.NoFreeAccount | Free tier is used up. |
UnsupportedOperation.PkgExhausted | The resource package is used up. |
UnsupportedOperation.ServerAlreadyOpen | Server opened. |
UnsupportedOperation.ServerDestoryed | The service is already terminated. |
UnsupportedOperation.ServerNotOpen | Service inactivated. |
UnsupportedOperation.ServerStopped | Service stopped. |
UnsupportedOperation.TextTooLong | The text is too long. See the description of the request parameter Text . |
本页内容是否解决了您的问题?