Skip to main content
Vane Data / Reference

resample

resample converts an AUDIOFILE into a Float64 tensor of shape (frames, channels) at a target sample rate. The complete stream is trimmed or zero-padded at the end, independent of chunk sizes.

Signature

example.py
vane.resample(
    value, sample_rate,
    *, max_input_bytes=536870912, max_frames=100000000, max_decoded_bytes=536870912,
    max_output_frames=100000000, max_output_bytes=536870912,
) -> Expression

SQL: resample(file, rate [, max_input_bytes, max_frames, max_decoded_bytes, max_output_frames, max_output_bytes]). There is no Expression method for resample.

Parameters

NameTypeDescriptionDefault
valueAUDIOFILE value or ExpressionEncoded audio object to resampleRequired
sample_ratePositive integer or ExpressionTarget sample rate in HzRequired
max_input_bytesInteger or ExpressionEncoded input limit512 MiB
max_framesInteger or ExpressionPer-input decoded-frame limit100,000,000
max_decoded_bytesInteger or ExpressionDecoded sample budget512 MiB
max_output_framesInteger or ExpressionResampled output-frame limit100,000,000
max_output_bytesInteger or ExpressionResampled output-byte limit512 MiB

The native backend requires a target and source rate in 1–384000 Hz and 1–64 channels. The Python backend accepts any positive target rate, up to 1024 channels, and a rate ratio of at most 64×.

Returns and errors

Returns TENSOR(DOUBLE, [NULL, NULL]) with shape (frames, channels); mono keeps one channel and empty audio yields (0, channels). NULL inputs return NULL; unsupported rates, channel counts, codec mismatches, and limit breaches raise.

Example

example.py
import vane


con = vane.connect()
waveform = con.sql("SELECT resample(audio_file('sample.wav'), 16000)").fetchone()[0]
assert waveform.shape[1] >= 1
vane.close()