pyflink.multimodal.operators.audio_encode#
- audio_encode(*columns, format='wav', concurrency=None)[source]#
Encode
AUDIO_WAVEFORMto bytes.- Parameters
*columns – Optional audio columns. Supported input is
AUDIO_WAVEFORMonly.format – Encoded output format. Common values are
"wav","flac","ogg","aiff", and"mp3". Actual availability depends on the worker’ssoundfile/libsndfile runtime. PyFlink writes a stable default subtype for each supported format; if the current libsndfile runtime does not support that subtype, the operator fails instead of silently choosing an environment-dependent subtype.concurrency – UDF concurrency.
Noneuses the framework default.
- Returns
A UDF producing encoded
BYTES.- Raises
ValueError – If the input is not
AUDIO_WAVEFORMor the format is unsupported, if the default output subtype is unavailable in the current libsndfile runtime, or if waveform samples containNaN/Inf.
- Examples::
>>> # Usage 1: create a reusable UDF and apply it to a column. >>> encode = audio_encode(format="wav") >>> df = df.with_column("wav", encode(col("waveform"))) >>> >>> # Usage 2: pass the column directly when building the expression. >>> df = df.with_column("wav", audio_encode(col("waveform"), format="wav"))