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

Lake AI Service

Copy page
Download PDF
Audio recognition
Speech-to-text (FireRed)
Copy page
Download PDF
Speech-to-text (FireRed)

Operator introduction

Description

Speech recognition module – a multilingual speech-to-text solution based on the FireRed ASR model

Key features

  • Multilingual recognition: Supports Chinese, English, and Chinese dialects
  • Multiple model selection: Supports various models, including AED models and LLM models
  • Audio type: Supports mono, 16 kHz sampling rate wav audio files

  • To ensure recognition quality, for AED models, it is recommended that the audio length does not exceed 60 seconds; for LLM models, it is recommended that the audio length does not exceed 30 seconds
  • When performing batch inference with LLM models, it is recommended to ensure that the audio lengths are similar. If the difference is large, set batch_size=1
  • It is recommended to standardize the audio before use and convert it to a supported audio file format

Supported models

  • FireRedASR-AED-L
  • FireRedASR-LLM-L

Daft invocation

Operator parameters

Input

Input column name

Note

contents

An array containing audio data, with each element being a string (file path or URL). Supports local file paths as well as remote file links starting with tos://, s3://, http://, or https://

contents_ids

An array containing audio data, with each element being a string used to uniquely identify the audio. Default value: None

Output

Processed array, with each element being the transcription for each audio file. For audio files that fail to process, an empty string is returned.

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

FireRedAsr/FireRedASR-AED-L

Model name. Supported FireRed series models: - FireRedAsr/FireRedASR-AED-L: Small model - FireRedAsr/FireRedASR-LLM-L: Large model Optional values: [ "FireRedAsr/FireRedASR-AED-L", "FireRedAsr/FireRedASR-LLM-L" ] Default value: "FireRedAsr/FireRedASR-AED-L"

batch_size

int

1

Number of audio samples processed at one time. Default value: 1

beam_size

int

3

Beam width during decoding. Controls the search space size during decoding; the larger the value, the higher the possible recognition accuracy but the slower the speed. Default value: 3

decode_min_len

int

0

Minimum decoding length Restricts the minimum length of the output text. 0 means no restriction. Default value: 0

decode_max_len

int

0

Maximum decoding length Restricts the maximum length of the output text. 0 means no restriction. Default value: 0

nbest

int

1

Number of AED model output candidates Controls the number of candidate texts output. Only effective for AED models. Default value: 1

softmax_smoothing

float

1.25

AED model softmax smoothing coefficient Adjusts the smoothness of the softmax distribution. Only effective for AED models. Default value: 1.25

aed_length_penalty

float

0.6

AED model length penalty Controls the penalty coefficient for the output text length. Only effective for AED models. Default value: 0.6

eos_penalty

float

1.0

AED model end-of-sequence penalty Controls the penalty coefficient for the end-of-sequence token. Only effective for AED models. Default value: 1.0

repetition_penalty

float

3.0

LLM model repetition penalty Controls the penalty coefficient for repeated content when generating text. Only effective for LLM models. Default value: 3.0

llm_length_penalty

float

1.0

LLM model length penalty Controls the penalty coefficient for the generated text length. Only effective for LLM models. Default value: 1.0

temperature

float

1.0

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

use_fp16

bool

False

Use FP16 inference Enables half-precision floating-point accelerated inference to save GPU memory. Default value: False

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 daft
from daft import col
from daft.las.functions.audio.audio_asr_firered import AudioAsrFireRed
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")
    audio_src_type = "audio_url"
    beam_size = 3
    decode_min_len = 0
    decode_max_len = 100
    nbest = 1
    softmax_smoothing = 1.25
    aed_length_penalty = 0.6
    eos_penalty = 1.0
    repetition_penalty = 3.0
    llm_length_penalty = 1.0
    temperature = 1.0
    use_fp16 = True
    batch_size = 1
    num_gpus = 1

    df = daft.from_pydict(samples)

    # Each UDF requires one GPU. If there is only one GPU, please comment out the code for one UDF and run only the other.
    df = df.with_column(
        "asr_result_aed",
        las_udf(
            AudioAsrFireRed,
            construct_args={
                "audio_src_type": audio_src_type,
                "model_path": model_path,
                "model_name": "FireRedAsr/FireRedASR-AED-L",
                "batch_size": batch_size,
                "beam_size": beam_size,
                "decode_min_len": decode_min_len,
                "decode_max_len": decode_max_len,
                "nbest": nbest,
                "softmax_smoothing": softmax_smoothing,
                "aed_length_penalty": aed_length_penalty,
                "eos_penalty": eos_penalty,
            },
            num_gpus=num_gpus,
            batch_size=1,
            concurrency=1,
        )(col("audio_path")),
    )

    df = df.with_column(
        "asr_result_llm",
        las_udf(
            AudioAsrFireRed,
            construct_args={
                "audio_src_type": audio_src_type,
                "model_path": model_path,
                "model_name": "FireRedAsr/FireRedASR-LLM-L",
                "batch_size": batch_size,
                "beam_size": beam_size,
                "decode_min_len": decode_min_len,
                "decode_max_len": decode_max_len,
                "repetition_penalty": repetition_penalty,
                "llm_length_penalty": llm_length_penalty,
                "use_fp16": use_fp16,
                "temperature": temperature,
            },
            num_gpus=num_gpus,
            batch_size=1,
            concurrency=1,
        )(col("audio_path")),
    )
    df.show()

    # ╭────────────────────────────────┬────────────────────────────────────────────┬───────────────────────────────────────────╮
    # │ audio_path                     ┆ asr_result_aed                             ┆ asr_result_llm                            │
    # │ ---                            ┆ ---                                        ┆ ---                                       │
    # │ Utf8                           ┆ Utf8                                       ┆ Utf8                                      │
    # ╞════════════════════════════════╪════════════════════════════════════════════╪═══════════════════════════════════════════╡
    # │ https://las-cn-beijing-publ…   ┆ I kept myself safe, got the gold, I, old Sun, do not care about fame, only wish to return ┆ I kept myself safe, got the gold, I, old Sun, do not care about fame, only wish to         │
    # │                                ┆ to Flower Fruit Mountain and spend the rest of my life there…                             ┆ return to Flower Fruit Mountain and live out my days there…                          │
    # ╰────────────────────────────────┴────────────────────────────────────────────┴───────────────────────────────────────────╯
Last updated: 2026.05.12 19:06:34