Hi, it would be great to support loading in float16 dtype. Many autonomous audio recorders used for wildlife monitoring record very long, float16 files, and loading them as float32 doubles the memory usage unnecessarily. Currently, only ['float32', 'float64', 'int16', 'int32'] are supported by sf.load()
It seems like the crux is that ctypes does not have float16
|
_ffi_types: Final[dict[str, str]] = { |
the audio frame loading happens in
|
def _cdata_io(self, action, data, ctype, frames): |
which is called by SoundFile.read() via :
|
def _array_io(self, action, array, frames): |
Perhaps it would be possible to cast frames to float16 immediately when loading into python, to avoid the memory overhead of creating the entire array as float32?
Hi, it would be great to support loading in float16 dtype. Many autonomous audio recorders used for wildlife monitoring record very long, float16 files, and loading them as float32 doubles the memory usage unnecessarily. Currently, only ['float32', 'float64', 'int16', 'int32'] are supported by sf.load()
It seems like the crux is that ctypes does not have float16
python-soundfile/soundfile.py
Line 149 in 3503941
the audio frame loading happens in
python-soundfile/soundfile.py
Line 1426 in 3503941
which is called by SoundFile.read() via :
python-soundfile/soundfile.py
Line 1412 in 3503941
Perhaps it would be possible to cast frames to float16 immediately when loading into python, to avoid the memory overhead of creating the entire array as float32?