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

Lake AI Service

Copy page
Download PDF
Audio processing
Audio denoising (MossFormer2_SE_48K)
Copy page
Download PDF
Audio denoising (MossFormer2_SE_48K)

Operator introduction

Description

Use MossFormer2_SE_48K for audio denoising

Key features

  • Use MossFormer2_SE_48K for audio denoising
  • Supports local files and TOS storage (tos, s3, http, https, and other schemas)

Format support

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

Examples

Operator parameters

Input

Input column name

Note

audio_path

Column for storing the audio path

output_path

Column for storing the path of the denoised audio

Output

If denoising is successful, the operator outputs the path of the denoised audio; if it fails, it returns None.

Parameters

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

Parameter name

Type

Default value

Description

model_path

str

/opt/las/models

Model directory. In LAS, this is always set to the default value.

model_name

str

MossFormer2_SE_48K

Model name. In LAS, this is always set to the default value.

max_duration

str

7200

If the audio duration exceeds this value (in seconds), the audio will be split and then denoised.

output_format

str

None

The format of the denoised audio. By default, it matches the input audio format. Optional values include 'flac', 'mp3', 'm4a', 'wav', 'ogg', 'aac', and more.

Examples

The following code demonstrates how to use Daft to run the operator for audio denoising.

from __future__ import annotations

import logging
import os

import ray

import daft
from daft import col
from daft.las.functions.audio.audio_denoise import AudioDenoise
from daft.las.functions.udf import las_udf

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)

configure_logging()

if __name__ == "__main__":
    TOS_INPUT_DIR_URL = os.getenv("TOS_INPUT_DIR_URL", "las-cn-beijing-public-online.tos-cn-beijing.volces.com")
    TOS_OUTPUT_DIR = os.getenv("TOS_OUTPUT_DIR", "las-cn-beijing-public-online")
    samples = {
        "input_path": [os.path.join(f"https://{TOS_INPUT_DIR_URL}", "public/shared_audio_dataset/黑神话悟空对话.mp3")],
        "output_path": [os.path.join(f"tos://{TOS_OUTPUT_DIR}", "public/output/黑神话悟空对话_denoised.mp3")],
    }
    # To output to output_path, you need to set authentication information such as tos access_key and secret_key. In the Volcano Engine environment, TOS_ENDPOINT can use an internal address to improve upload and download speed
    # os.environ["TOS_ACCESS_KEY"] = os.getenv("TOS_ACCESS_KEY", "aksk")
    # os.environ["TOS_SECRET_KEY"] = os.getenv("TOS_SECRET_KEY", "aksk")
    # os.environ["TOS_ENDPOINT"] = os.getenv("TOS_ENDPOINT", "https://tos-cn-beijing.volces.com")
    # os.environ["TOS_REGION"] = os.getenv("TOS_REGION", "cn-beijing")

    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)

    df_samples = daft.from_pydict(samples)

    df = df_samples.with_column(
        "result_path",
        las_udf(
            AudioDenoise,
            construct_args={
                "model_path": "/opt/las/models",
            },
            num_gpus=1,
            concurrency=1,
            batch_size=2,
        )(col("input_path"), col("output_path")),
    )

    df.show(max_width=120, format="grid")

    # ┌────────────────────────────────────┬───────────────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────────────┐
    # │ audio_path                         │ output_path                                                       │ result_path                                                        │
    # ╞════════════════════════════════════╪═══════════════════════════════════════════════════════════════════╪════════════════════════════════════════════════════════════════════╡
    # │ tos://xxxxx/黑神话悟空对话.mp3 │ tos://xxxxx/output/黑神话悟空对话_denoised.mp3 │ tos://xxxxx/output/黑神话悟空对话_denoised.mp3 │
    # └────────────────────────────────────┴───────────────────────────────────────────────────────────────────┴────────────────────────────────────────────────────────────────────┘
Last updated: 2026.05.12 19:06:33