I made an example of reading audio with ffmpg in C (deallocation is also done in C), calling it from Python, and reading it into a PyTorch tensor via DLPack: https://github.com/vadimkantorov/readaudio 2
A simpler example of just demonstating my DLPack Python / NumPy bindings: https://github.com/vadimkantorov/pydlpack 4
Managing memory is not very sure, as I’m not very confident about NumPy / Python array / object lifecycle. If you take a look or find problems, feel free to drop into GitHub issues!