Content | Description |
Voice types | Supports synthesis of Mandarin Chinese, English, and dialects. For voice IDs, see the Voice List page. You can set the corresponding voice ID via the VoiceType API parameter. |
Supported Scenarios | General, customer service, emotional, reading, news, and so on. For details, see the Voice List page. |
Audio properties | Sampling rate: 16000Hz or 8000Hz Sampling precision: 16 bits Channels: mono |
Audio formats | pcm,mp3 |
Request protocol | wss protocol |
Request URL | wss://tts.cloud.tencent.com/stream_ws?{request parameters} |
API authentication | |
Response format | Audio information is returned as raw binary data via binary-type frames. text information is returned as JSON-format data (such as status codes, timestamps, and so on) via text-type frames. |
Concurrency limit | By default, a single account is limited to 20 concurrent streams (shared with the real-time TTS API). If you need to increase the concurrency limit, contact your business manager for consultation. |
Field Name | Type | Description |
code | Integer | The status code. 0 indicates normal, and a non-zero value indicates that an error has occurred. |
message | String | Error description. It displays the specific cause of the error when an error occurs. This text may be frequently updated or changed as business evolves or user experience is optimized. |
session_id | String | The unique ID of the audio stream. It is generated by the client during the handshake phase and assigned to the call parameters. |
request_id | String | The unique ID of the audio stream. It is automatically generated by the server during the handshake phase. |
message_id | String | The unique ID of this message. |
result | Result | The latest TTS text result. |
final | Integer | When this field returns 1, it indicates that the text synthesis is complete. Upon receiving this, the client must actively close the WebSocket connection. |
Field Name | Type | Description |
subtitles | Subtitle Array | The word list for the current passage, with the Subtitle struct format as follows: Text: A String-type field containing the content of the character. BeginTime: An Integer-type field indicating the start time of the character within the entire audio stream. EndTime: An Integer-type field indicating the end time of the character within the entire audio stream. BeginIndex: An Integer-type field indicating the start position of the character within the entire text, starting from 0. EndIndex: An Integer-type field indicating the end position of the character within the entire text, starting from 0. Phoneme: A String-type field containing the phoneme of the character. (Note: This field may return null, indicating that no valid value can be obtained.) |
wss://tts.cloud.tencent.com/stream_ws?{request_parameters}
key1=value2&key2=value2...(Both keys and values must be URL-encoded)
Parameter Name | Required | Type | Description |
Action | Yes | String | The name of the API to call. Value: TextToStreamAudioWS. |
AppId | Yes | Integer | The AppId of the account. Ensure that the data type of this field is int. |
AccountArea | No | Integer | International account identifier. Value: 0: Indicates a domestic account (default). 1: Indicates an international account. |
SecretId | Yes | String | |
Timestamp | Yes | Integer | The current UNIX timestamp, which records the time when the API request is initiated. For example, 1529223702. If it differs too much from the current time, a signature expiration error will occur. |
Expired | Yes | Integer | The validity period of the signature. It is a value that conforms to the UNIX Epoch timestamp specification, measured in seconds. Expired must be greater than Timestamp, and (Expired - Timestamp) must be less than 90 days. |
SessionId | Yes | String | The globally unique identifier for TTS. One WebSocket connection corresponds to one identifier. It is generated by the user (UUID is recommended) and can be up to 128 bits in length. |
Text | Yes | String | The source text for speech synthesis. The length is uniformly calculated based on UTF-8 encoding. Chinese text supports a maximum of 600 Chinese characters (full-width punctuation marks count as one character). English text supports a maximum of 1800 letters (half-width punctuation marks count as one letter). |
VoiceType | No | Integer | Attention: If you are using the one-sentence version of VRS, enter the fixed value "200000000". |
FastVoiceType | No | String | The voice ID for one-shot VRS. Required when a one-shot VRS voice is used. |
Volume | No | Float | The volume level. Its range is [-10, 10], which corresponds to the actual volume. The default value is 0, representing the normal volume level. A larger value indicates a higher volume. |
Speed | No | Float | Speech rate. Range: [-2, 6], corresponding to different speech rates: -2: Indicates 0.6 times. -1: Indicates 0.8 times. 0: Indicates 1.0 times (default). 1: Indicates 1.2 times. 2: Indicates 1.5 times. 6: Indicates 2.5 times. If you need a more granular speech rate, you can keep two decimal places, for example, 0.5/1.25/2.81, and so on. |
SampleRate | No | Integer | Audio sample rate 16000: 16k (default) 8000:8k |
Codec | Yes | String | Returned audio format pcm: Returns binary pcm audio. mp3: Returns binary mp3 audio. |
EnableSubtitle | No | Boolean | Whether to enable the timestamp feature. The default value is false. |
SegmentRate | No | Integer | Sentence segmentation sensitivity threshold. Value range: [0,1,2]. Default value: 0. A larger value makes sentence segmentation less likely to occur, and the model tends to segment sentences only based on punctuation marks. It is recommended not to adjust this parameter arbitrarily, as doing so may affect the synthesis quality. |
Signature | Yes | String | API signature parameter |
Action=TextToStreamAudioWS&AppId=130046****&Codec=pcm&EnableSubtitle=True&Expired=1688697305&SampleRate=16000&SecretId=*****XcaKs2w4vZw5zTCrHRM7dOwre9*****&SessionId=b78ae3ba-1ba5-11ee-a106-768645a5c72a&Speed=0&Text=Welcome to Tencent Cloud Real-time TTS&Timestamp=1688610905&VoiceType=101001&Volume=0
Request method (GET) + Domain address (tts.cloud.tencent.com/stream_ws) + Request parameters (?Action=TextToStreamAudioWS&other parameters...)
GETtts.cloud.tencent.com/stream_ws?Action=TextToStreamAudioWS&AppId=130046****&Codec=pcm&EnableSubtitle=True&Expired=1688697305&SampleRate=16000&SecretId=*****XcaKs2w4vZw5zTCrHRM7dOwre9*****&SessionId=b78ae3ba-1ba5-11ee-a106-768645a5c72a&Speed=0&Text=Welcome to Tencent Cloud Real-time TTS&Timestamp=1688610905&VoiceType=101001&Volume=0
SecretKey=*****SkqpeHgqmSz*****, encrypt it using the HMAC-SHA1 algorithm and then perform base64 encoding:Base64Encode(HmacSha1("GETtts.cloud.tencent.com/stream_ws?Action=TextToStreamAudioWS&AppId=130046****&Codec=pcm&EnableSubtitle=True&Expired=1688697305&SampleRate=16000&SecretId=*****XcaKs2w4vZw5zTCrHRM7dOwre9*****&SessionId=b78ae3ba-1ba5-11ee-a106-768645a5c72a&Speed=0&Text=Welcome to Tencent Cloud Real-time TTS&Timestamp=1688610905&VoiceType=101001&Volume=0", "*****SkqpeHgqmSz*****"))
U6O4dLlz3mgj6ONKUkO/0g4u5pk=
wss://tts.cloud.tencent.com/stream_ws?Action=TextToStreamAudioWS&AppId=130046****&Codec=pcm&EnableSubtitle=True&Expired=1688697305&SampleRate=16000&SecretId=*****XcaKs2w4vZw5zTCrHRM7dOwre9*****&SessionId=b78ae3ba-1ba5-11ee-a106-768645a5c72a&Speed=0&Text=Welcome to Tencent Cloud Real-time TTS&Timestamp=1688610905&VoiceType=101001&Volume=0&Signature=4Lv%2Bk6y6v5VRT/iBFPU%2BGyfeiy0%3D
Text=Welcome to Tencent Cloud Real-time TTSReplace withText=%E6%AC%A2%E8%BF%8E%E4%BD%BF%E7%94%A8%E8%85%BE%E8%AE%AF%E4%BA%91%E5%AE%9E%E6%97%B6%E8%AF%AD%E9%9F%B3%E5%90%88%E6%88%90
wss://tts.cloud.tencent.com/stream_ws?Action=TextToStreamAudioWS&AppId=130046****&Codec=pcm&EnableSubtitle=True&Expired=1688697305&SampleRate=16000&SecretId=*****XcaKs2w4vZw5zTCrHRM7dOwre9*****&SessionId=b78ae3ba-1ba5-11ee-a106-768645a5c72a&Speed=0&Text=%E6%AC%A2%E8%BF%8E%E4%BD%BF%E7%94%A8%E8%85%BE%E8%AE%AF%E4%BA%91%E5%AE%9E%E6%97%B6%E8%AF%AD%E9%9F%B3%E5%90%88%E6%88%90&Timestamp=1688610905&VoiceType=101001&Volume=0&Signature=4Lv%2Bk6y6v5VRT/iBFPU%2BGyfeiy0%3D
{"code":0,"message":"success","session_id":"e042008c-1019-11ee-8b49-6c92bf65e6fe","request_id":"b028dfe6-d7af-4d25-b61d-dcae685aa81f","message_id":"f81c0771-5606-478e-9560-555a5717ea25","final":0,"result":{"subtitles":null}}
{"code":0,"message":"success","session_id":"659f1260-101a-11ee-959d-6c92bf65e6fe","request_id":"20ebf801-53ee-4a58-96ab-c63e0f16044a","message_id":"8d4a2f2b-3b15-445c-933b-74b6b44cd882","final":0,"result":{"subtitles":[{"Text":"Welcome","BeginTime":250,"EndTime":570,"BeginIndex":0,"EndIndex":1,"Phoneme":"huan1"},{"Text":"to","BeginTime":570,"EndTime":770,"BeginIndex":1,"EndIndex":2,"Phoneme":"ying2"},{"Text":"Tencent","BeginTime":770,"EndTime":1020,"BeginIndex":2,"EndIndex":3,"Phoneme":"shi3"},{"Text":"Cloud","BeginTime":1020,"EndTime":1270,"BeginIndex":3,"EndIndex":4,"Phoneme":"yong4"}]}}
{"code":0,"message":"success","session_id":"dbb8417e-101a-11ee-840e-6c92bf65e6fe","request_id":"99207183-3bda-42de-a1f4-6d8838122ad3","message_id":"d56a3fed-0dd6-4dc6-b434-416ae1b69f0f","final":1,"result":{"subtitles":null}}
{"code":10001,"message":"Invalid parameter (Please check your parameter VoiceType)","session_id":"b6b10dc0-101a-11ee-9e72-6c92bf65e6fe","request_id":"a2edbe4f-c12f-48e6-8810-fda7a0992f79","message_id":"da63be2f-d44e-4f3b-a2d7-0b19a3748d23","final":0,"result":{"subtitles":null}}

Value | Description |
10001 | Invalid parameter. For details, refer to the message field. |
10002 | Concurrent call limit exceeded for the account. |
10003 | Authentication Failure |
10004 | Client data upload timeout |
10005 | Client connection disconnected |
20000 | Backend Error |
20001 | Backend server synthesis failure |
20002 | Backend engine synthesis failure |
20003 | Backend engine synthesis timeout |
피드백