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_standardize#

audio_standardize(*columns, sample_rate=16000, channels=1, concurrency=None)[source]#

Standardize an audio waveform.

The operator resamples when needed and converts channel count when needed. The default 16000 Hz mono target matches Whisper-style speech model input contracts. Channel conversion downmixes multi-channel input by averaging channels when the target is mono. Mono-to-multi conversion duplicates the mono channel. Multi-to-different-multi conversion downmixes to mono first, then duplicates to the requested channel count.

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

  • sample_rate – Target sample rate in samples per second.

  • channels – Target channel count.

  • concurrency – UDF concurrency. None uses the framework default.

Returns

A UDF producing ROW<data TENSOR('float32'), sample_rate INT, channels INT, frames BIGINT, sample_format STRING, layout STRING, duration_ms BIGINT, source_uri STRING, start_time_ms BIGINT, end_time_ms BIGINT>. The output keeps source and segment fields from the input when present.

Raises

ValueError – If the input is not an audio waveform row, or if sample_rate or channels is invalid.

Examples::
>>> decode = audio_decode()
>>> waveform = decode(col("audio_bytes"))
>>> # Usage 1: create a reusable UDF and apply it to a column.
>>> standardize = audio_standardize(sample_rate=16000, channels=1)
>>> df = df.with_column(
...     "speech_ready",
...     standardize(waveform),
... )
>>>
>>> # Usage 2: pass the column directly when building the expression.
>>> df = df.with_column(
...     "speech_ready",
...     audio_standardize(waveform, sample_rate=16000, channels=1),
... )

previous

pyflink.multimodal.operators.audio_convert_format

next

pyflink.multimodal.operators.audio_resample

Show Source

Created using Sphinx 4.5.0.