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

audio_encode(*columns, format='wav', concurrency=None)[source]#

Encode AUDIO_WAVEFORM to bytes.

Parameters
  • *columns – Optional audio columns. Supported input is AUDIO_WAVEFORM only.

  • format – Encoded output format. Common values are "wav", "flac", "ogg", "aiff", and "mp3". Actual availability depends on the worker’s soundfile/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. None uses the framework default.

Returns

A UDF producing encoded BYTES.

Raises

ValueError – If the input is not AUDIO_WAVEFORM or the format is unsupported, if the default output subtype is unavailable in the current libsndfile runtime, or if waveform samples contain NaN/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"))

previous

pyflink.multimodal.operators.audio_decode

next

pyflink.multimodal.operators.audio_convert_format

Show Source

Created using Sphinx 4.5.0.