Ctrl+K
Logo image Logo image

Site Navigation

  • API Reference
  • Examples

Site Navigation

  • API Reference
  • Examples

Section Navigation

  • PyFlink DataFrame
  • PyFlink Multimodal
    • Image
    • Video
    • Audio
    • Utilities
  • PyFlink Table
  • PyFlink DataStream
  • PyFlink Common

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_db for at least min_silence_ms. No ASR or VAD model is used.

threshold_db is required because silence is corpus dependent: a noisy call-center recording and a studio recording need different thresholds. min_silence_ms defaults to 0 so the operator does not hide a second corpus-specific heuristic. Tune both values for the input domain. Use audio_detect_speech for speech activity detection; silence ranges are not equivalent to speech ranges.

Parameters
  • *columns – Optional audio columns. Supported input is AUDIO_WAVEFORM only; call audio_decode first for encoded inputs.

  • threshold_db – Required silence threshold in dB relative to full-scale float waveform amplitude. It must be <= 0; for example -40.0 means frames at or below -40 dBFS are treated as silence. 0 means 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. None uses the framework default.

Returns

A UDF producing ARRAY<ROW<start_ms BIGINT, end_ms BIGINT, duration_ms BIGINT>>. For waveform rows decoded from AUDIO_CLIP_REF segments, start_ms and end_ms are reported in the source audio timeline so they can be fed into timestamp-based split operators.

Raises

ValueError – If the input is not AUDIO_WAVEFORM or 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),
... )

previous

pyflink.multimodal.operators.audio_size_filter

next

pyflink.multimodal.operators.audio_detect_speech

Show Source

Created using Sphinx 4.5.0.