pyflink.multimodal.operators.audio_split_by_speech#
- audio_split_by_speech(*columns, segment_type='audio', pre_padding_ms=0, post_padding_ms=0, merge_gap_ms=0, min_segment_ms=0, max_segment_ms=None, max_segments=1024, concurrency=None)[source]#
Split audio by speech activity ranges into one output row per segment.
The second input column must contain speech ranges with
start_msandend_msfields, such as output from a VAD or upstream speech activity model. This operator does not detect speech by itself; it only applies padding, merging, filtering, and splitting to caller-provided ranges. Ranges outside the actual audio duration are clipped, and fully out-of-range ranges are dropped. SQL module calls putsegment_typebefore the optional tuning arguments. Useaudio_split_by_speech(uri, ranges, 'ref')for default lazy references, or provide all tuning literals asaudio_split_by_speech(uri, ranges, 'ref', 200, 200, 30, 30, 1000, 1024).- Parameters
*columns – Audio input followed by speech activity ranges.
segment_type="audio"supports waveform rows.segment_type="ref"supports URISTRINGand reference rows.segment_type –
"audio"for materialized waveform rows or"ref"for reference rows.pre_padding_ms – Milliseconds to extend before each speech range.
post_padding_ms – Milliseconds to extend after each speech range.
merge_gap_ms – Merge adjacent ranges separated by this gap or less.
min_segment_ms – Drop segments shorter than this duration after padding and merging.
max_segment_ms – Optionally split long speech ranges into chunks no longer than this value.
max_segments – Maximum allowed number of returned segments.
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, if speech ranges or split parameters are 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_speech( ... pre_padding_ms=200, ... post_padding_ms=200, ... ) >>> segments = df.join_lateral( ... split(col("waveform"), col("speech_ranges")).alias("segment") ... ) >>> >>> # Usage 2: pass columns directly when joining laterally. >>> segments = df.join_lateral( ... audio_split_by_speech( ... col("waveform"), ... col("speech_ranges"), ... pre_padding_ms=200, ... post_padding_ms=200, ... ).alias("segment") ... )