Skip to main content
Vane Data / Reference

Audio functions

Audio functions inspect AUDIOFILE metadata and resample waveforms into Float64 tensors of shape (frames, channels). The connection's audio_backend (python by default, native with the loaded native_media extension) selects the SoundFile/SoXR path or the C++ path; both resample with SoXR HQ and return exactly ceil(decoded_frames * target_rate / source_rate) frames. audio_metadata and resample have a Python form and a SQL form; audio_metadata also has an Expression method form. audio_file is the AUDIOFILE constructor.

Choose an API

FunctionPythonSQLNative implementationReturns
audio_metadata✓✓native_audio_metadataMetadata STRUCT
resample✓✓native_audio_resampleTENSOR(DOUBLE, [NULL, NULL])
native_audio_resample_profile—✓native_audio_resample_profileDiagnostic STRUCT

native_audio_resample_profile is a native-only diagnostic registered by the native_media extension.

Python AudioFile values

vane.AudioFile exposes bound-method equivalents that always use the Python implementation:

MethodReturns
AudioFile.metadata(*, max_bytes=8388608)AudioMetadata with sample rate, channels, frames, duration, format, and subtype
AudioFile.to_numpy(buffer_size=1048576, *, max_input_bytes=536870912, max_frames=100000000, max_decoded_bytes=536870912)Float64 (frames, channels) NumPy array
AudioFile.resample(sample_rate, buffer_size=1048576, *, max_input_bytes=536870912, max_frames=100000000, max_decoded_bytes=536870912, max_output_frames=100000000, max_output_bytes=536870912)Resampled Float64 (frames, channels) NumPy array

metadata inspects headers without decoding, to_numpy decodes the complete stream, and resample uses SoXR HQ. Failures raise AudioFileError or its AudioFileFormatError / AudioFileLimitError subclasses.

Backends

  • python (default): SoundFile/SoXR. Install vane-ai[audio].
  • native: the loaded native_media extension. Set audio_backend = 'native' before binding the query. An unavailable extension fails during binding; there is no automatic fallback.
example.py
import vane


con = vane.connect()
vane.load_installed_extension("native_media", connection=con)
con.execute("SET audio_backend = 'native'")

Returns and errors

NULL inputs propagate to NULL waveforms. Unsupported rates, channel counts, codec mismatches, resource-limit breaches, missing audio dependencies, and cancellation propagate as errors. SQL execution caps flattened sample storage at 256 MiB per vector batch.