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
16000Hz 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_WAVEFORMonly; callaudio_decodefirst for encoded inputs.sample_rate – Target sample rate in samples per second.
channels – Target channel count.
concurrency – UDF concurrency.
Noneuses 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_rateorchannelsis 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), ... )