Configure Translation
Feature Overview
During real-time speech recognition (ASR), you can enable the translation feature to translate recognized audio content into the target language in real-time.
- This feature supports the following two main configuration modes:
- Room-level translation: All streams in the room share one translation configuration.
- Stream-level translation: Set personalized translation configurations for different streams in the room (e.g., different target languages).
- Supported translation vendors/models. For the translation languages supported by each vendor, refer to the official documentation of the corresponding model:
- Doubao doubao-seed-translation: The Volcengine Ark doubao-seed-translation translation model, ByteDance's self-developed multilingual translation model that supports dozens of languages with faithful and fluent translations. For details, refer to doubao-seed-translation model description.
- Tongyi Qianwen Qwen-MT: The Alibaba Cloud Bailian Qwen-MT machine translation large model, optimized based on Qwen3, supporting translation between 92 languages. For details, refer to Translation Capability Qwen-MT.
- Google Translate: Google Cloud Translation API (v2), which uses the nmt neural machine translation model by default and supports translation between 100+ languages. For details, refer to Google Cloud Translation documentation. (Note: Only available on overseas clusters)
- Supported methods for obtaining translation results:
- Server callback to get translation results.
- Real-time audio/video room signaling (ZEGO Express SDK) callback.
Prerequisites
- Use a translation model supported by ZEGO cloud real-time speech recognition.
- Have activated the service of the corresponding translation vendor and obtained the model's API Key.
How to Use
When creating a real-time speech recognition task (StartRealtimeASRTask) or adding recognition streams (AddStream), enable translation with EnableTranslation and configure the vendor, source language, target language, and other parameters in Translation:
- Room-level translation: Configure
EnableTranslationandTranslationat the task level, and all streams in the room share this translation configuration. - Stream-level translation: Configure
EnableTranslationandTranslationfor each stream inStreamList(e.g., different target languages). WhenRecognitionRangeis1, the system reads the stream-level configuration first, and falls back to the outerEnableTranslationandTranslationif the stream-level configuration is missing.
Translation Parameters
The translation-related parameters for creating a real-time speech recognition task are as follows:
| Parameter | Type | Required | Description |
|---|---|---|---|
RecognitionRange | Int | No | Recognition range. 0: entire room, 1: specified StreamList |
StreamList | array of object | No | List of streams to recognize, effective when RecognitionRange is 1 |
EnableTranslation | Bool | No | Whether to enable translation |
Translation | Object | No | Translation LLM configuration item |
SubtitleType | Int | No | Subtitle delivery type via room signaling, default is 0:
1, 2, or 3 |
The translation-related parameters in StreamList are as follows:
| Parameter | Type | Required | Description |
|---|---|---|---|
StreamId | String | Yes | Stream ID to recognize |
ASR | Object | No | Refer to ASR Parameters |
EnableTranslation | Bool | No | Whether to enable translation |
Translation | Object | No | Translation LLM configuration item |
Translation
| Parameter | Type | Required | Description |
|---|---|---|---|
Vendor | String | Yes | Translation service vendor:
|
SourceLanguage | String | No | Source language. The value must be an enum value of the corresponding translation vendor. For GoogleTranslateV2, it can be omitted or set to an empty string for automatic source language detection. |
TargetLanguage | String | Yes | Target language |
LLM | Object | Yes | LLM parameters, see the table below |
SourceLanguage and TargetLanguage need to reference the enumeration values of the corresponding translation vendor. For sample configurations of each vendor, refer to the Using different translation vendors section.LLM
| Parameter | Type | Required | Description |
|---|---|---|---|
Url | String | Depends on vendor | LLM endpoint, which varies by vendor:
|
ApiKey | String | No | LLM verification API key. Default is empty. Make sure to fill in the corresponding API key in production environments. |
Model | String | Depends on vendor | Model to call, which varies by vendor:
|
Params | Object | No | Request parameters for the LLM or application platform. For supported parameters, refer to the official documentation of the corresponding model. GoogleTranslateV2 does not support passing through parameters. |
AdvancedConfig
| Parameter | Type | Required | Description |
|---|---|---|---|
TranslationRoomMessageMode | Int | No | RTC room message delivery mode for translated text:
SubtitleType is 2 or 3, and does not affect ASR subtitles or HTTP callbacks. For subtitle message formats, refer to Display Subtitles. |
Usage Examples
Start a Recognition Task with Translation and Display Translation Results on the Client
Get Translation Results
Get Translation Results via the Server (Non-streaming)
Refer to the Receiving Callbacks documentation to get the Data result of the Event being TranslationResult.
(Optional) Display Subtitles on the Client
To display translation subtitles, refer to the Display Subtitles documentation.
Using different translation vendors
The detailed description and sample calls for each vendor are as follows (for supported translation languages, refer to each vendor's official documentation):
