pyflink.multimodal.operators.audio_resample#
- audio_resample(*columns, sample_rate, concurrency=None)[source]#
Resample an audio waveform.
This changes the sample rate while preserving the channel count. Use
audio_standardizewhen both sample rate and channel layout should be normalized.- Parameters
*columns – Optional audio columns. Supported input is
AUDIO_WAVEFORMonly; callaudio_decodefirst for encoded inputs.sample_rate – Target sample rate in samples per second.
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>.- Raises
ValueError – If the input is not an audio waveform row, or if
sample_rateis invalid.
- Examples::
>>> # Usage 1: create a reusable UDF and apply it to a column. >>> resample = audio_resample(sample_rate=8000) >>> df = df.with_column("resampled", resample(col("waveform"))) >>> >>> # Usage 2: pass the column directly when building the expression. >>> df = df.with_column( ... "resampled", ... audio_resample(col("waveform"), sample_rate=8000), ... )