spdl.io.load_wav¶
- load_wav(data: bytes, time_offset_seconds: float | None = None, duration_seconds: float | None = None) ArrayInterface [source]¶
Extract audio samples from WAV data.
- Parameters:
data – Binary WAV data as bytes
time_offset_seconds – Optional starting time in seconds (default: 0.0)
duration_seconds – Optional duration in seconds (default: until end)
- Returns:
- Object exposing audio samples through the Array Interface Protocol.
The object can be consumed by NumPy (np.asarray) and other libraries supporting the array interface. The underlying array has shape (num_samples, num_channels). The dtype depends on bits_per_sample:
8 bits: uint8
16 bits: int16
32 bits: int32 or float32
64 bits: float64
- Return type:
- Raises:
ValueError – If the WAV data is invalid or time range is out of bounds.
See also
- Benchmark wav
A benchmark script that compares the performance of
load_wav
function withload_audio()
andlibsoundfile
.