Operator ID: daft.las.functions.audio.audio_concat_fast.AudioConcatFast
Fast audio concatenation processor (same-source audio)
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 |
An array containing the paths of the concatenated audio files; returns the output path on success, returns None on failure
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) |
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… │ # ╰───────────────────┴───────────────────╯