You need to enable JavaScript to run this app.
AI 数据湖服务

AI 数据湖服务

复制全文
音频处理
音频静音检测
复制全文
音频静音检测

算子介绍

描述

音频静音检测处理器,智能识别音频是否为完全静音

核心功能

  • 静音检测:分析整个音频文件,判断是否为静音
  • 可配置阈值:支持自定义静音检测的敏感度阈值(dB)
  • 高效处理:优化的音量分析算法,处理速度快
  • 精确分析:通过专业音量检测技术判断静音状态
  • 支持本地文件、HTTP/HTTPS URL和TOS/S3存储

格式支持

  • 输入:MP3、WAV、FLAC、AAC、M4A、OGG等主流音频格式
  • 检测算法:基于专业音量分析技术
  • 采样率:自动适配各种采样率
  • 声道:支持单声道和多声道音频

检测原理

  • 音量阈值检测:分析音频的最大音量和平均音量
  • 静音判断:当最大音量低于设定阈值时,认为音频为静音
  • 无损分析:采用专业音频处理技术,保证分析精度

Daft 调用

算子参数

输入

输入列名

说明

audio_inputs

存放音频路径或二进制的列

输出

存放静音检测结果的布尔值列,True表示静音,False表示非静音,None表示处理失败或没有声道

参数

如参数没有默认值,则为必填参数

参数名称

类型

默认值

描述

silence_threshold_db

float

-60.0

静音音量阈值(dB),当音频最大音量低于此值时认为是静音 默认值:-60.0 (dB)

timeout

int or None

None

单个音频处理超时时间(秒),为None时不限制 默认值:None

调用示例

下面的代码展示了如何使用 Daft(适用于分布式)运行算子对音频进行静音检测。

from __future__ import annotations

import os

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

if __name__ == "__main__":
    TOS_TEST_DIR_URL = os.getenv("TOS_TEST_DIR_URL", "las-cn-beijing-public-online.tos-cn-beijing.volces.com")

    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.context.set_runner_ray()

    daft.set_execution_config(actor_udf_ready_timeout=600)
    daft.set_execution_config(min_cpu_per_task=0)

    samples = {
        "input_path": [
            f"https://{TOS_TEST_DIR_URL}/public/archive/audio_silence_detection/sample_silence.wav",
            f"https://{TOS_TEST_DIR_URL}/public/archive/audio_silence_detection/sample_speech.wav",
        ],
    }
    ds = daft.from_pydict(samples)

    # Using Daft to detect silence in audio files
    constructor_kwargs = {
        "silence_threshold_db": -60.0,
        "timeout": 30,
    }

    ds = ds.with_column(
        "is_silence",
        las_udf(
            AudioSilenceDetection,
            construct_args=constructor_kwargs,
            num_cpus=1,
            concurrency=1,
            batch_size=1,
        )(col("input_path")),
    )

    ds.show()
    # ╭────────────────────────────────┬────────────╮
    # │ input_path                     ┆ is_silence │
    # │ ---                            ┆ ---        │
    # │ String                         ┆ Bool       │
    # ╞════════════════════════════════╪════════════╡
    # │ https://las-public-data-qa.to… ┆ true       │
    # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
    # │ https://las-public-data-qa.to… ┆ false      │
    # ╰────────────────────────────────┴────────────╯
最近更新时间:2026.01.08 19:15:09
这个页面对您有帮助吗?
有用
有用
无用
无用