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

Lake AI Service

Copy page
Download PDF
Audio processing
Fast audio concatenation (same source)
Copy page
Download PDF
Fast audio concatenation (same source)

Operator ID: daft.las.functions.audio.audio_concat_fast.AudioConcatFast

Operator introduction

Description

Fast audio concatenation processor (same-source audio)

  • Uses concat demuxer to quickly concatenate same-source audio (no re-encoding required)
  • Applicable to audio files with identical format, codec, sample rate, and channel count
  • Concatenate segments from the same recording
  • Concatenate audio clips with the same format
  • For scenarios requiring fast concatenation without format conversion

Key features

  • High speed, no quality loss
  • Supports multiple input formats: local file paths, TOS/S3 storage paths, HTTP/HTTPS paths
  • Supports output to a specified path

Format support and requirements

  • Supports common audio formats: mp3, wav, flac, aac, m4a, and more
  • Requirement: All input audio must have the same format, codec, sample rate, and channel count

Difference from AudioConcat

  • AudioConcat: Uses concat filter, supports audio with different formats, requires re-encoding
  • AudioConcatFast: Uses concat demuxer, supports only same-source audio, no re-encoding required, faster speed

Daft invocation

Operator parameters

Input

Input column name

Note

audio_paths_list

Column containing a list of audio file paths; each element is a list of strings

output_col

Array containing the output audio file paths

Output

An array containing the paths of the concatenated audio files; returns the output path on success, returns None on failure

Parameters

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

Parameter name

Type

Default value

Description

output_format

str

mp3

Output audio format (used only to determine the file extension), default is "mp3". Note: Because concat demuxer is used, the output format should match the input audio format.

timeout

int or None

None

ffmpeg execution timeout (seconds), default is None (no timeout)

Examples

The following code demonstrates how to use Daft (for distributed environments) to run the operator for fast concatenation of same-source audio files (no re-encoding required).

from __future__ import annotations

import os

import daft
from daft import col
from daft.las.functions.audio import AudioConcatFast
from daft.las.functions.udf import las_udf

if __name__ == "__main__":
    # The converted audio will be saved to the specified TOS path. Therefore, environment variables must be set to ensure write permissions to TOS, including: ACCESS_KEY, SECRET_KEY, TOS_ENDPOINT, TOS_REGION, TOS_TEST_DIR
    TOS_TEST_DIR_URL = os.getenv("TOS_TEST_DIR_URL", "las-cn-beijing-public-online.tos-cn-beijing.volces.com")
    TOS_TEST_DIR = os.getenv("TOS_TEST_DIR", "tos_bucket")

    if os.getenv("DAFT_RUNNER", "native") == "ray":
        import logging

        import 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",
            )
            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)

        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)

    samples = {
        "audio_paths": [
            [
                f"https://{TOS_TEST_DIR_URL}/public/archive/audio_concat_fast/sample_a.wav",
                f"https://{TOS_TEST_DIR_URL}/public/archive/audio_concat_fast/sample_b.wav",
            ],
        ],
        "output_path": [f"tos://{TOS_TEST_DIR}/audio_concat_fast/output/concatenated_audio_fast.wav"],
    }
    ds = daft.from_pydict(samples)

    # Using Daft to concatenate audio files (fast, no re-encoding)
    constructor_kwargs = {
        "output_format": "wav",  # Same as input format
    }

    ds = ds.with_column(
        "output_path",
        las_udf(
            AudioConcatFast,
            construct_args=constructor_kwargs,
            num_cpus=1,
            concurrency=1,
            batch_size=1,
        )(col("audio_paths"), col("output_path")),
    )

    ds.show()
    # ╭───────────────────┬───────────────────╮
    # │ audio_paths                    ┆ output_path                    │
    # │ ---                            ┆ ---                            │
    # │ List[String]                   ┆ String                         │
    # ╞═══════════════════╪═══════════════════╡
    # │ [https://las-public-data-qa.t… ┆ tos://tos_bucket/audio_concat… │
    # ╰───────────────────┴───────────────────╯
Last updated: 2026.05.12 19:06:33