Intelligent workflow configuration best practices

Updated at:
Copy as MD

Intelligent workflows enable modular, customizable media processing pipelines. This topic provides configuration examples for live stream translation and RTC caption recognition.

Scenario 1: Live stream translation

An intelligent workflow performs speech recognition on a live stream, generates real-time translations, and sends the intermediate and final results for each sentence to your HTTP server through a callback.

Overall topology configuration

image

The topology includes six nodes: Start, Automatic Speech Recognition (ASR), Large Language Model (LLM), Code Execution, HTTP Request, and End.

The node configurations are as follows:

Start node

image

When you start the workflow, pass the following input parameters to the Start node:

{
  "live_url": {
      "Url": "rtmp://test.com/test_app/test_stream?auth_key=test",
      "MaxIdleTime": 20
  },
  "source_language_id": "es"
}

Parameter

Required

Description

live_url

Yes

Pass as an Object with the following fields:

  • Url: A publicly accessible live streaming URL.

  • MaxIdleTime: The timeout period for pulling the live stream. The task stops if no data is received for more than 20 seconds.

source_language_id

Yes

The source language. Select a value from the following list.

Mandarin Chinese: zh
English: en
Spanish: es
Japanese: ja
Korean: ko
French: fr
Thai: th
Russian: ru
German: de
Guangxi dialect: guangxi
Portuguese: pt
Cantonese: yue
Traditional Cantonese: yue_hant
Minnan: minnan
Polish: pl
Italian: it
Ukrainian: uk
Dutch: nl
Arabic: ar
Indonesian: id
Turkish: tr
Vietnamese: vi

ASR node

image

Set the input variable to the live_url parameter of the Start node, and set the input language to the source_language_id parameter of the Start node. Leave the other parameters as default or configure them as needed.

LLM node

image

This example configures the qwen-mt-turbo model using the Custom Model Integration (OpenAI-compliant) method. For more information about how to obtain an API key, see Obtain an API Key. In the model parameters, set the source language (which can be set to `auto`) and the target language. The user prompt can directly reference the intermediate or final results from the ASR node.

Code execution node

image

To merge the ASR and LLM translation results for the callback, use a Python script in the Code Execution node. Set the LLM output to the TransText field of the ASR result, then return a JSONObject as the callback data.

HTTP request node

image

Configure the following settings:

  • API configuration: The public address of your callback server.

  • URL parameters: result_type=mid_en. You can customize the callback type.

  • Request body type: json.

  • Request body data: Reference the JSON output from the callback data.

Scenario 2: RTC caption recognition

An intelligent workflow performs ASR on a specified audio stream in a Real-Time Communication (RTC) channel. The recognition results are sent to the client through a DataChannel callback to display captions.

Overall topology configuration

image

The topology includes four nodes: Start, ASR, RTC Ingest, and End.

The node configurations are as follows:

Start node

image

Variable descriptions:

  • rtc: When you start the workflow, pass the RTC parameters. These include AppId, ChannelId, and UserId. You also need to select the output audio stream.

  • source_language_id: The source language for recognition.

  • push_app_id: The RTC AppId for the DataChannel callback.

  • push_channel_id: The RTC ChannelId for the DataChannel callback.

  • push_uid: The RTC UserId for the DataChannel callback.

Variable example:

{
  "rtc": {
    "AppId": "xxx",
    "ChannelId": "rtcaitest1",
    "UserId": "userA"
  },
  "source_language_id": "zh",
  "push_app_id": "app_id",
  "push_channel_id": "channel_id",
  "push_uid": "user_id"
}

ASR node

image

Set the input variable to the audio from the live stream input of the Start node, and set the input language to the source_language_id parameter of the Start node. Leave the other parameters at their default values or customize them as needed.

RTC ingest node

image

The text input variable must reference the output text from the ASR node. The App ID, channel ID, and user ID correspond to the push_app_id, push_channel_id, and push_uid fields of the Start node and represent the role information for DataChannel stream ingest.