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

Lake AI Service

Copy page
Download PDF
Audio processing
Audio file size calculation
Copy page
Download PDF
Audio file size calculation

Operator introduction

Description

Audio file metadata analysis processor for accurately calculating file size
Key features

  • Accurately calculates the byte size of audio files
  • Supports local files and TOS storage
  • Lightweight and efficient, suitable for batch processing

Format support

  • MP3 (.mp3)
  • WAV (.wav)
  • FLAC (.flac)
  • OGG (.ogg)
  • AAC (.aac)
  • M4A (.m4a)

Daft invocation

Operator parameters

Input

Input column name

Description

audio_paths

Column for storing audio file paths

Output

Column for storing audio file size

Examples

The following code demonstrates how to use daft to run the operator for calculating audio file size.

from __future__ import annotations

import os

import daft
from daft import col
from daft.las.functions.audio.audio_size import AudioSize
from daft.las.functions.udf import las_udf

if __name__ == "__main__":
    TOS_TEST_DIR = os.getenv("TOS_TEST_DIR", "tos_bucket")
    samples = {"audio_path": [f"tos://{TOS_TEST_DIR}/audio_size/sample.mp3"]}

    df = daft.from_pydict(samples)
    df = df.with_column("size_result", las_udf(AudioSize)(col("audio_path")))

    df.show()
    # ╭────────────────────────────────┬─────────────╮
    # │ audio_path                     ┆ size_result │
    # │ ---                            ┆ ---         │
    # │ Utf8                           ┆ Float32     │
    # ╞════════════════════════════════╪═════════════╡
    # │ tos://tos_bucket/audio_size/s… ┆ 795426      │
    # ╰────────────────────────────────┴─────────────╯
Last updated: 2026.05.12 19:06:33