Content | Description |
Language type | Supports translation between Chinese, English, and other languages. You can set the corresponding language types through the interface parameters source and target. |
audio attribute | Sample rate: 16000 Hz Sample precision: 16 bits Channel: mono |
Audio format | pcm,wav |
request protocol | wss protocol |
Request URL | wss://asr.cloud.tencent.com/asr/speech_translate/?{Request parameters} |
API authentication | |
response format | Uniformly uses JSON format. |
data transmission | It is recommended to send a data packet of 200 ms duration (that is, a 1:1 real-time rate) every 200 ms. The corresponding PCM size is 6400 bytes at a 16 kHz sample rate. If the audio is sent at a rate exceeding the 1:1 real-time rate, or if the interval between audio data packets exceeds 6 seconds, the engine may encounter an error. In this case, the backend will return an error and proactively disconnect the connection. |
concurrency limit | By default, the concurrency limit per account is 5. If you need a higher concurrency limit, submit a ticket for consultation. |
Field Name | Type | Description |
code | Integer | Status code. 0 indicates normal, and a non-zero value indicates that an error occurred. |
message | String | Error description. When an error occurs, display the specific reason for the error occurrence. As the business develops or experience optimization progresses, this text may be frequently changed or updated. |
voice_id | String | Globally unique identifier of the audio stream. One identifier corresponds to one WebSocket connection. User-generated (UUID recommended), with a maximum length of 128 characters. Note: A new voice_id must be generated each time a WebSocket connection is established. If the translation or WebSocket connection is interrupted for any reason (such as connection failure, normal termination, or a translation error code), the voice_id becomes invalid, and a new voice_id must be used to restart the translation. |
sentence_id | String | Unique ID of the current sentence. |
result | Result | Latest speech translation result. |
final | Integer | When this field returns 1, it indicates that the translation of the audio stream is complete. When it returns 2, it indicates that the synthesis of the translated text is complete. |
Field Name | Type | Description |
source | String | Source language type, such as "zh", "en", "zh_en", and so on. zh: Chinese en: English zh_en: Chinese-English mixed ja: Japanese ko: Korean yue: Cantonese id: Indonesian th: Thai ru: Russian Example value: zh. |
target | String | Target language type, such as "zh", "en", "zh_en", and so on. zh: Chinese en: English zh_en: Chinese-English mixed ja: Japanese ko: Korean yue: Cantonese id: Indonesian th: Thai ru: Russian Example value: en. |
source_text | String | Recognized source language text content, encoded in UTF-8. Example value: ASR speech recognition result. |
target_text | String | Translated target language text content, encoded in UTF-8. Example value: ASR speech recognition results. |
start_time | Integer | Start time of the current sentence in the entire audio stream, in milliseconds. Example value: 1000. |
end_time | Integer | End time of the current sentence in the entire audio stream, in milliseconds. Example value: 3000. |
sentence_end | Boolean | Whether the current sentence ends. true indicates that the sentence ends, and false indicates that the sentence has not ended. Example value: true. |
wss://asr.cloud.tencent.com/asr/speech_translate/<appid>?{Request parameters}
key1=value2&key2=value2...
Parameter Name | Required | Type | Description |
secretid | Yes | String | The SecretID of the Tencent Cloud registered account can be obtained on the API Key Management page. Example value: *****Qq1zhZMN8dv0****** |
signature | Yes | String | API signature parameters Example value: *****g1JfeBi%2FYnTjyjekxfDA%3D |
timestamp | Yes | Integer | Current UNIX timestamp in seconds. If the value differs too much from the current time, a signature expiration error will occur. Example value: 1745932688 |
expired | Yes | Integer | UNIX timestamp of the signature expiration time, in seconds. expired must be greater than timestamp, and expired - timestamp must be less than 90 days. Example value: 1746019088 |
nonce | Yes | Integer | A random positive integer. It must be generated by the user and can contain up to 10 digits. Example value: 8743357 |
voice_id | Yes | String | Globally unique identifier of the audio stream. One identifier corresponds to one WebSocket connection. User-generated (UUID recommended), with a maximum length of 128 characters. Note: A new voice_id must be generated each time a WebSocket connection is established. If the translation or WebSocket connection is interrupted for any reason (such as connection failure, normal termination, or a translation error code), the voice_id becomes invalid, and a new voice_id must be used to restart the translation. Example value: TBgVFCsxdn3i2DGt |
voice_format | Yes | Integer | Speech encoding format. 1: pcm; 12: wav Example value: 1 |
source | Yes | String | Source language type. Supported language types: zh: Chinese en: English zh_en: Chinese-English mixed ja: Japanese ko: Korean yue: Cantonese id: Indonesian th: Thai ru: Russian Example value: zh. |
target | Yes | String | Target language type. The supported target languages for each source language are listed below: zh (Chinese): zh (Chinese), en (English), ja (Japanese), ko (Korean), yue (Cantonese), id (Indonesian), th (Thai) en (English): zh (Chinese), en (English), ja (Japanese), ko (Korean), yue (Cantonese), id (Indonesian), th (Thai) zh_en (Chinese-English mixed): zh_en (Chinese-English mixed), zh (Chinese), en (English), ja (Japanese), ko (Korean), yue (Cantonese), id (Indonesian), th (Thai) ja (Japanese): zh (Chinese), en (English), ja (Japanese), ko (Korean), yue (Cantonese) ko (Korean): zh (Chinese), en (English), ja (Japanese), ko (Korean), yue (Cantonese) yue (Cantonese): zh (Chinese), en (English), ja (Japanese), ko (Korean), yue (Cantonese) id (Indonesian): zh (Chinese), en (English), id (Indonesian) th (Thai): zh (Chinese), en (English), th (Thai) ru (Russian): zh (Chinese), en (English), ru (Russian) Note: If both source and target are set to zh_en, Chinese is automatically translated into English, and English is automatically translated into Chinese. Example value: en. |
trans_model | Yes | String | Translation model type. Supported models: hunyuan-translation-lite: Lite edition hunyuan-translation: Standard edition Example value: hunyuan-translation-lite |
hotword_list | No | String | Temporary hotword list: This parameter is used to improve recognition accuracy. ● Single hotword limit: "hotword|weight". A single hotword cannot exceed 30 characters (up to 10 Chinese characters). The weight ranges from 1 to 11 or is 100, for example, "Tencent Cloud|5" or "ASR|11". ● Temporary hotword list limit: Multiple hotwords are separated by commas. A maximum of 128 hotwords is supported, for example, "Tencent Cloud|10,ASR|5,ASR|11". Note: ● When the hotword weight is set to 11, the current hotword is upgraded to a super hotword. It is recommended to set only important and mandatory hotwords to 11. Setting too many hotwords with a weight of 11 will affect the overall character accuracy rate. ● When the hotword weight is set to 100, the current hotword enables the enhanced homophone and same-tone replacement feature (only supported for 8k_zh and 16k_zh). For example, when the hotword is configured as "mizhi|100", the recognition result of "mizhi", which shares the same pinyin (mizhi) as "mizhi", will be forcibly replaced with "mizhi". Therefore, it is recommended that customers enable this feature based on their actual needs. It is recommended to set only important and mandatory hotwords to 100. Setting too many hotwords with a weight of 100 will affect the overall character accuracy rate. ● Hotwords cannot contain spaces, for example, ASR Tencent Cloud. Example value: Voice Assistant|10 |
filter_dirty | No | Integer | Whether to filter out dirty words (currently effective only when the source language is zh or zh_en). The default value is 0. 0: Do not filter out dirty words; 1: Filter out dirty words; 2: Replace dirty words with "*". Example value: 0. |
filter_modal | No | Integer | Whether to filter out filler words (currently effective only when the source language is zh or zh_en). The default value is 0. 0: Do not filter out modal particles; 1: Partially filter out; 2: Strictly filter out. Example value: 0. |
filter_punc | No | Integer | Whether to filter out periods at the end of sentences (currently effective only when the source language is zh or zh_en). The default value is 0. 0: Do not filter out periods at the end of sentences; 1: Filter out periods at the end of sentences. Example value: 0. |
convert_num_mode | No | Integer | Whether to perform intelligent conversion of Arabic numerals (currently effective only when the source language is zh or zh_en). The default value is 1. 0: Do not convert, but directly output Chinese numerals; 1: Intelligently convert to Arabic numerals based on the scenario; 3: Enable math-related numeral conversion. Example value: 1. |
noise_threshold | No | Float | The noise parameter threshold defaults to 0 and ranges from -2 to 2. For some audio segments, a larger value indicates a higher likelihood of being classified as noise, while a smaller value indicates a higher likelihood of being classified as speech. Example value: 0. |
domain | No | Integer | Domain-specific name, 1: Technology; 2: Movie; 3: Song |
vad_silence_time | No | int | Voice segmentation detection threshold. Silence duration exceeding the threshold is considered as sentence segmentation. Value range: 500-2000 (default: 1000), in ms. Currently only supports source language types: zh, en, and zh_en. Example value: 1000. |
max_speak_time | No | int | Forced sentence segmentation feature. Value range: 5000-90000 (unit: ms), default value: 10000. In continuous speaking without interruption, this parameter implements forced sentence segmentation (at this point the result becomes steady state, sentence_end=true). (Currently only supports source language types: zh, en, and zh_en) |
appid=125922*** and secretid=*****Qq1zhZMN8dv0****** as an example to concatenate the original text for signing, the concatenated original text is:asr.cloud.tencent.com/asr/speech_translate/125922***?expired=1673494772&nonce=1673408372&secretid=*****Qq1zhZMN8dv0******&source=zh&target=en×tamp=1673408372&trans_model=hunyuan-translation-lite&voice_format=1&voice_id=c64385ee-3e5c-4fc5-bbfd-7c71addb35b0
secretkey=*****SkqpeHgqmSz*****, encrypt it using the HMAC-SHA1 algorithm and then encode it with base64:Base64Encode(HmacSha1("asr.cloud.tencent.com/asr/speech_translate/125922***?expired=1673494772&nonce=1673408372&secretid=*****Qq1zhZMN8dv0******&source=zh&target=en×tamp=1673408372&trans_model=hunyuan-translation-lite&voice_format=1&voice_id=c64385ee-3e5c-4fc5-bbfd-7c71addb35b0", "*****SkqpeHgqmSz*****"))
G8jDQBRg1JfeBi/YnTjyjekxfDA=
wss://asr.cloud.tencent.com/asr/speech_translate/125922****?expired=1673494772&nonce=1673408372&secretid=A*********************************0r&source=zh&target=en×tamp=1673408372&trans_model=hunyuan-translation-lite&voice_format=1&voice_id=c64385ee-3e5c-4fc5-bbfd-7c71addb35b0&signature=G8jDQBRg1JfeBi%2FYnTjyjekxfDA%3D
{"code":0,"message":"success","voice_id":"RnKu9FODFHK5FPpsrN"}
{"type": "end"}
{"code":0,"message":"success","voice_id":"RnKu9FODFHK5FPpsrN","sentence_id":"0669d099-ffdf-404e-ad91-5eaff18b20df","result":{"source":"zh","target":"en","source_text":"Real time","target_text":"Real time","start_time":0,"end_time":1240,"sentence_end":false}}
{"code":0,"message":"success","voice_id":"RnKu9FODFHK5FPpsrN","sentence_id":"0669d099-ffdf-404e-ad91-5eaff18b20df","result":{"source":"zh","target":"en","source_text":"Real time voice translation","target_text":"Real time voice translation","start_time":0,"end_time":2840,"sentence_end":true}}
{"code":0,"message":"success","voice_id":"CzhjnqBkv8lk5pRUxhpX","final":1}
{"code":6008,"message":"The client has not sent audio data for more than 15 seconds.","voice_id":"CzhjnqBkv8lk5pRUxhpX"}
Value | Description |
6000 | Excessive audio data is sent. Send at most 3 seconds of audio data within 1 second. Note: The effect of real-time translation is to output recognition and translation results while speaking. The total duration of audio data sent within 1 second should be 1 second. |
6001 | The parameter is invalid. |
6002 | Authentication failed. |
6003 | The account has not enabled this service. Enable the service in the console. |
6004 | The resource package is exhausted. Enable postpaid billing or purchase a resource package. |
6005 | The service is suspended due to overdue payment. Recharge your account promptly. |
6006 | The account's current concurrent calls exceed the limit. |
6007 | Audio decoding failed. Check that the uploaded audio data format is consistent with the call parameters. |
6008 | The client has not sent audio data for more than 15 seconds. |
6009 | The client connection is disconnected. |
6010 | The client uploaded an unknown text message. |
6011 | The audio data shard is too large. Adjust the shard size according to the documentation. |
6012 | The request failed due to high machine load or network jitter. Initiate the request again. Note: This issue is usually occasional. A small number of occurrences can be ignored. Initiate a new request. |
6013 | The request failed due to high machine load or network jitter. Initiate the request again. Note: This issue is usually occasional. A small number of occurrences can be ignored. Initiate a new request. |
7000 | The request failed due to high machine load or network jitter. Initiate the request again. Note: This issue is usually occasional. A small number of occurrences can be ignored. Initiate a new request. |
피드백