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 withuri,start_time_ms, andend_time_msfields; downstream operators can decode only the segments they need. SQL module calls putsegment_typebeforemax_segments. For example, useaudio_split_by_duration(uri, 30000, 'ref')for lazy references, oraudio_split_by_duration(waveform, 30000, 'audio', 1024)when overridingmax_segments.- Parameters
*columns – Optional audio columns.
segment_type="audio"supports waveform rows.segment_type="ref"supports URISTRINGand 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
ValueErrorinstead of silently truncating data.concurrency – UDF concurrency.
Noneuses the framework default.
- Returns
A UDTF producing one
segmentcolumn per emitted segment. Forsegment_type="audio",segmentis a waveform row withdata 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. Forsegment_type="ref",segmenthasuri STRING, start_time_ms BIGINT, end_time_ms BIGINT.- Raises
ValueError – If the input does not match
segment_type, ifsegment_duration_msormax_segmentsis invalid, or if the split would produce more thanmax_segmentsitems.
- 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") ... )