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

audio_split_by_duration(*columns, segment_duration_ms, segment_type='audio', max_segments=1024, concurrency=None)[source]#

Split audio by fixed duration into one output row per segment.

segment_type="audio" materializes decoded waveform segments. segment_type="ref" returns lazy reference segments with uri, start_time_ms, and end_time_ms fields; downstream operators can decode only the segments they need. SQL module calls put segment_type before max_segments. For example, use audio_split_by_duration(uri, 30000, 'ref') for lazy references, or audio_split_by_duration(waveform, 30000, 'audio', 1024) when overriding max_segments.

Parameters
  • *columns – Optional audio columns. segment_type="audio" supports waveform rows. segment_type="ref" supports URI STRING and reference rows.

  • segment_duration_ms – Segment duration in milliseconds.

  • segment_type – "audio" for materialized waveform rows or "ref" for reference rows.

  • max_segments – Maximum allowed number of returned segments. Exceeding the limit raises ValueError instead of silently truncating data.

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

Returns

A UDTF producing one segment column per emitted segment. For segment_type="audio", segment is a waveform row with 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. For segment_type="ref", segment has uri STRING, start_time_ms BIGINT, end_time_ms BIGINT.

Raises

ValueError – If the input does not match segment_type, if segment_duration_ms or max_segments is invalid, or if the split would produce more than max_segments items.

Examples::
>>> # Usage 1: create a reusable UDTF and join it laterally.
>>> split = audio_split_by_duration(segment_duration_ms=30000)
>>> segments = df.join_lateral(split(col("waveform")).alias("segment"))
>>>
>>> # Usage 2: pass the column directly when joining laterally.
>>> segments = df.join_lateral(
...     audio_split_by_duration(
...         col("waveform"),
...         segment_duration_ms=30000,
...     ).alias("segment")
... )
>>>
>>> # Usage 1: create a reusable UDTF for lazy reference segments.
>>> ref_split = audio_split_by_duration(
...     segment_duration_ms=30000,
...     segment_type="ref",
... )
>>> segments = df.join_lateral(ref_split(col("uri")).alias("segment"))
>>>
>>> # Usage 2: pass the URI column directly for lazy reference segments.
>>> segments = df.join_lateral(
...     audio_split_by_duration(
...         col("uri"),
...         segment_duration_ms=30000,
...         segment_type="ref",
...     ).alias("segment")
... )

previous

pyflink.multimodal.operators.audio_resample

next

pyflink.multimodal.operators.audio_split_by_timestamp

Show Source

Created using Sphinx 4.5.0.