You need to enable JavaScript to run this app.
Lake AI Service

Lake AI Service

Copy page
Download PDF
Audio recognition
Language identification and ASR (Whisper series models)
Copy page
Download PDF
Language identification and ASR (Whisper series models)

Operator introduction

Description

This operator can be used for language identification modules. It is a multilingual LID (Language Identification**,** language identification) + ASR (Automatic Speech Recognition, automatic speech recognition) solution based on the Whisper model.

Key features

  • Multilingual recognition: Supports nearly one hundred languages including Chinese and English; also supports outputting language tags alongside the recognized text (for example, en, zh).
  • Punctuation restoration: Customizable punctuation restoration for Chinese and English to improve the readability of the output text.
  • Supports multiple audio input formats: URL, binary, and more

Supported models

  • Whisper series models (LID + ASR)
    • openai/whisper-large-v3-turbo
    • openai/whisper-large-v3
    • openai/whisper-medium (Chinese support is limited)
    • openai/whisper-small (may output traditional Chinese characters)
  • Chinese and English punctuation restoration model
    • iic/punc_ct-transformer_cn-en-common-vocab471067-large

Language support

Supports nearly one hundred languages including Chinese, English, German, Spanish, and more. See the complete language list. ‌

  • Supports multiple audio input formats (URL, binary, and more)
  • Batch processing of audio segments up to 30 seconds long
  • Recognition accuracy is usually highest for English scenarios
  • Punctuation restoration models can optionally be used for Chinese and English scenarios to improve text readability
  • Supports returning only language identification results
  • Supports GPU-accelerated inference; it is recommended to use CUDA devices with more than 4 GB of GPU memory

Daft invocation

Operator parameters

Input

Input column name

Note

audios

An array containing audio data. Each element can be audio_url (the URL of the audio file or TOS object storage path, which will be downloaded locally and decoded) or audio_binary (raw audio byte data, either decoded or raw audio binary).

Output

A structured result array, where each element is a struct containing the following fields:

  • asr_result (str): The text result obtained from speech recognition.
  • language (str): The recognized language code (for example, en, zh).
  • asr_result_with_punc (Optional[str]): Optional text result with punctuation. Returned when the punctuation model is loaded and available during initialization; otherwise, None.

Parameters

If a parameter does not have a default value, it is required.

Parameter name

Type

Default value

Description

audio_src_type

str

Type of input audio source. Supports audio_url (URL of the audio file or TOS object storage path) and audio_binary (raw audio binary data). Ensure that the format is consistent with the format of the provided audios data.

model_path

str

/opt/las/models

Root directory path for models, typically containing several model subdirectories.

model_name

str

openai/whisper-large-v3

Model name. Supported Whisper series models include: whisper-small (small model), whisper-medium (medium model), whisper-large-v3 (latest large model), and whisper-large-v3-turbo (optimized large model). Optional values are: "openai/whisper-small", "openai/whisper-medium", "openai/whisper-large-v3-turbo", "openai/whisper-large-v3".

punc_model_name

Optional[str]

None

Optional punctuation restoration model name. Supports using iic/punc_ct-transformer_cn-en-common-vocab471067-large for Chinese and English punctuation restoration. If this parameter is provided, the operator will punctuate the recognized plain text and return it via the asr_result_with_punc field. If not provided or loading fails, this field will be None.

return_language_only

bool

False

Whether to return only the language recognition result without performing speech-to-text conversion. If set to True, both the asr_result and asr_result_with_punc fields will be None.

batch_size

int

10

Number of audio files processed per batch. Higher values increase throughput but also increase GPU/memory usage.

device

str

cpu

Inference device identifier, such as "cpu", "cuda", or "cuda:0". The default is "cpu".

Examples

The following code demonstrates how to use daft to run this operator for speech language identification and transcription.

from __future__ import annotations

import logging
import os

import ray

import daft
from daft import col
from daft.las.functions.audio.audio_asr_lid_whisper import AudioAsrLidWhisper
from daft.las.functions.udf import las_udf

if __name__ == "__main__":
    if os.getenv("DAFT_RUNNER", "ray") == "ray":

        def configure_logging():
            logging.basicConfig(
                level=logging.INFO,
                format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
                datefmt="%Y-%m-%d %H:%M:%S.%s".format(),
            )
            logging.getLogger("tracing.span").setLevel(logging.WARNING)
            logging.getLogger("daft_io.stats").setLevel(logging.WARNING)
            logging.getLogger("DaftStatisticsManager").setLevel(logging.WARNING)
            logging.getLogger("DaftFlotillaScheduler").setLevel(logging.WARNING)
            logging.getLogger("DaftFlotillaDispatcher").setLevel(logging.WARNING)

        import ray

        ray.init(dashboard_host="0.0.0.0", runtime_env={"worker_process_setup_hook": configure_logging})
        daft.set_runner_ray()

    daft.set_execution_config(actor_udf_ready_timeout=600)
    daft.set_execution_config(min_cpu_per_task=0)

    tos_dir_url = os.getenv("TOS_DIR_URL", "las-cn-beijing-public-online.tos-cn-beijing.volces.com")
    samples = {
        "audio_path": [
            f"https://{tos_dir_url}/public/shared_audio_dataset/sample_normal.wav"
        ]
    }

    model_path = os.getenv("MODEL_PATH", "/opt/las/models")
    model_name = "openai/whisper-large-v3"
    audio_src_type = "audio_url"
    punc_model_name = "iic/punc_ct-transformer_cn-en-common-vocab471067-large"
    num_gpus = 1
    device = "cuda" if num_gpus > 0 else "cpu"
    batch_size = 1
    return_language_only = False

    df = daft.from_pydict(samples)
    df = df.with_column(
        "asr_result_detail",
        las_udf(
            AudioAsrLidWhisper,
            construct_args={
                "audio_src_type": audio_src_type,
                "model_path": model_path,
                "model_name": model_name,
                "punc_model_name": punc_model_name,
                "return_language_only": return_language_only,
                "batch_size": batch_size,
                "device": device,
            },
            num_gpus=num_gpus,
            batch_size=1,
            num_cpus=4,
            concurrency=1,
        )(col("audio_path")),
    )

    df.show()

    # ╭───────────────────┬──────────────────────────────────────────╮
    # │ audio_path                     ┆ asr_result_detail                                                    │
    # │ ---                            ┆ ---                                                                  │
    # │ Utf8                           ┆ Struct[asr_result: Utf8, language: Utf8, asr_result_with_punc: Utf8] │
    # ╞═══════════════════╪══════════════════════════════════════════╡
    # │ https://las-cn-beijing-publi-… ┆ {asr_result: 人我保住了金我取到了俺老孙啥功名…                            │
    # ╰───────────────────┴──────────────────────────────────────────╯
Last updated: 2026.05.12 19:06:34