pyflink.multimodal.operators.audio_silence_detection#
- audio_silence_detection(*columns, threshold_db, min_silence_ms=0, concurrency=None)[source]#
Detect low-amplitude silence ranges in an
AUDIO_WAVEFORM.This is an energy-based silence detector, not a speech activity detector. It downmixes multi-channel waveform data to mono, computes frame RMS, converts RMS to decibels relative to full-scale amplitude, and returns ranges whose energy stays at or below
threshold_dbfor at leastmin_silence_ms. No ASR or VAD model is used.threshold_dbis required because silence is corpus dependent: a noisy call-center recording and a studio recording need different thresholds.min_silence_msdefaults to0so the operator does not hide a second corpus-specific heuristic. Tune both values for the input domain. Useaudio_detect_speechfor speech activity detection; silence ranges are not equivalent to speech ranges.- Parameters
*columns – Optional audio columns. Supported input is
AUDIO_WAVEFORMonly; callaudio_decodefirst for encoded inputs.threshold_db – Required silence threshold in dB relative to full-scale float waveform amplitude. It must be
<= 0; for example-40.0means frames at or below -40 dBFS are treated as silence.0means 0 dBFS/full scale, so almost all ordinary audio will be treated as silence.min_silence_ms – Minimum range length in milliseconds. Shorter quiet ranges are dropped.
concurrency – UDF concurrency.
Noneuses the framework default.
- Returns
A UDF producing
ARRAY<ROW<start_ms BIGINT, end_ms BIGINT, duration_ms BIGINT>>. For waveform rows decoded fromAUDIO_CLIP_REFsegments,start_msandend_msare reported in the source audio timeline so they can be fed into timestamp-based split operators.- Raises
ValueError – If the input is not
AUDIO_WAVEFORMor parameters are invalid.
- Examples::
>>> # Prepare a decoded waveform before applying silence detection. >>> decode = audio_decode() >>> waveform = decode(col("audio_bytes")) >>> # Usage 1: create a reusable UDF and apply it to a column. >>> silence = audio_silence_detection(threshold_db=-45.0) >>> df = df.with_column("silence_ranges", silence(waveform)) >>> >>> # Usage 2: pass the column directly when building the expression. >>> df = df.with_column( ... "silence_ranges", ... audio_silence_detection(waveform, threshold_db=-45.0), ... )