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

Lake AI Service

Copy page
Download PDF
Audio recognition
Speech-to-text (Whisper model series)
Copy page
Download PDF
Speech-to-text (Whisper model series)

Operator introduction

Description

Speech recognition module – Multilingual speech-to-text solution based on the Whisper model

Key features

  • Multilingual recognition: Supports major languages including Chinese and English
  • Speech translation: Recognition results can be translated into English

  • Audio segments within 30 seconds support batch_size > 1 to improve processing efficiency; otherwise, it is recommended to set batch_size to 1
  • Highest recognition accuracy in English scenarios

Supported models

  • openai/whisper-large-v3-turbo
  • openai/whisper-large-v3
  • openai/whisper-medium (Average support for Chinese)
  • openai/whisper-small (Chinese output is in traditional characters)

Language support

For the complete list of supported languages, please refer to: Supported languages list

Daft invocation

Operator parameters

Input

Input column name

Note

audios

Array containing audio data, supports the following formats:

  • audio_base64: Base64-encoded audio string;
  • audio_url: Audio file URL path;
  • audio_binary: Raw audio byte data

languages

Array of languages corresponding to each audio. For language abbreviations, please refer to Language abbreviations. If not provided here, the source_language parameter will be used.

Output

Processed structured array, each element contains the following fields:

  • asr_result: Speech recognition text result;
  • timestamps: List of timestamp pairs (start/end time);
  • segments: List of segmented text results

Parameters

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

Parameter name

Type

Default value

Description

audio_src_type

str

Audio format type Supported audio format types include: - tos/http address (audio_url) - Base64 encoding (audio_base64) - Binary stream (audio_binary) Optional values: ["audio_binary", "audio_url", "audio_base64"]

model_path

str

/opt/las/models

Model storage path Default value: "/opt/las/models"

model_name

str

openai/whisper-large-v3

Model name Supported Whisper series models: - whisper-small: Small model - whisper-medium: Medium model - whisper-large-v3: Latest large model - whisper-large-v3-turbo: Optimized large model Optional values: [ "openai/whisper-small", "openai/whisper-medium", "openai/whisper-large-v3-turbo", "openai/whisper-large-v3" ] Default value: "openai/whisper-large-v3"

batch_size

int

10

Number of audio samples processed per run Default value: 10

source_language

str

None

Audio source language Supported: chinese/english/japanese/korean and more. Can be set to None to enable automatic detection Default value: None

translate_to_english

bool

False

English translation mode Whether to translate recognition results into English. When enabled, the output text will be the English translation result Default value: False

condition_on_prev_tokens

bool

True

Historical dependency mode Whether to make predictions based on historical tokens. Disabling this option will reduce result coherence but improve processing speed. Default value: True

compression_ratio_threshold

float

1.35

Text compression threshold Controls the degree of compression for generated text (recommended range: 1.2–2.0). The larger the value, the more duplicate content is retained. Default value: 1.35

temperature

float

0.5

Temperature coefficient Controls the randomness of generated text (0.0–1.0). Higher values are suitable for creative scenarios, while lower values are suitable for deterministic scenarios. Default value: 0.5

logprob_threshold

float

-1.0

Log probability threshold The log probability threshold used to filter out words with low confidence. If a word's log probability is lower than this value, it may be rejected. The default is -1.0, which disables filtering and retains all words.

dtype

str

bfloat16

Computation precision type The numerical precision used for model inference: - bfloat16: Balances precision and speed (default) - float16: Faster inference speed - float32: Highest precision Optional values: ["bfloat16", "float16", "float32"] Default value: "bfloat16"

rank

int

0

GPU device number Specifies the GPU device ID to use (effective in multi-card environments). By default, the first GPU (ID=0) is used.

Examples

The following code demonstrates how to use daft to run the operator and convert speech to text.

from __future__ import annotations

import logging
import os

import ray

import daft
from daft import col
from daft.las.functions.audio.audio_asr_whisper import AudioAsrWhisper
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/.wav"
        ]
    }

    model_path = os.getenv("MODEL_PATH", "/opt/las/models")
    model_name = "openai/whisper-large-v3"
    audio_src_type = "audio_url"
    dtype = "bfloat16"
    source_language = "chinese"
    translate_to_english = False
    condition_on_prev_tokens = True
    compression_ratio_threshold = 1.35
    temperature = 0.5
    logprob_threshold = -1.0
    batch_size = 1
    rank = 0

    df = daft.from_pydict(samples)
    df = df.with_column(
        "asr_result_detail",
        las_udf(
            AudioAsrWhisper,
            construct_args={
                "audio_src_type": audio_src_type,
                "model_path": model_path,
                "model_name": model_name,
                "dtype": dtype,
                "source_language": source_language,
                "translate_to_english": translate_to_english,
                "condition_on_prev_tokens": condition_on_prev_tokens,
                "compression_ratio_threshold": compression_ratio_threshold,
                "temperature": temperature,
                "logprob_threshold": logprob_threshold,
                "batch_size": batch_size,
                "rank": rank,
            },
            num_gpus=1,
            batch_size=1,
            concurrency=1,
        )(col("audio_path")),
    )
    df.show()

    # ╭────────────────────────────────┬─────────────────────────────────────────────────────────────╮
    # │ audio_path                     ┆ asr_result_detail                                           │
    # │ ---                            ┆ ---                                                         │
    # │ Utf8                           ┆ Struct[asr_result: Utf8, timestamps: List[List[Float32]],   │
    # │                                ┆ segments: List[Utf8]]                                       │
    # ╞════════════════════════════════╪═════════════════════════════════════════════════════════════╡
    # │ tos://las-cn-beijing-publi-…   ┆ {asr_result: Visit Badaoling Great Wall,                                  │
    # │                                ┆ timesta…                                                    │
    # ╰────────────────────────────────┴─────────────────────────────────────────────────────────────╯
Last updated: 2026.05.12 19:06:34