vadimkantorov / readaudio

Read audio with FFmpeg into NumPy/PyTorch via ctypes (standard library module)
11 stars 2 forks source link

Libtorch integration #1

Open ghost opened 3 years ago

ghost commented 3 years ago

Hello, Did you test it with torch::tensor? I mean were you able to read a wav file into a C++ torch::tensor?

vadimkantorov commented 3 years ago

Nope, haven't tested, but it should be possible to do with torch::fromDlPack or torch::from_blob.

The current version isn't well tested, need to unroll some commits. And even then, I have an example of access violation. So take this as a code primer, not stable codebase

vadimkantorov commented 3 years ago

Also, if you need to just read audio without effects, then using sws_scale for resampling directly may be simpler: https://github.com/ac000/ffmpeg-libs-audio-transcode/blob/master/transcode.c#L146

ghost commented 3 years ago

Thanks! I shall give it a try and get back to you.

vadimkantorov commented 3 years ago

Also, for such usecase, there is probably no need of going through DLPack, and you can fill the tensor directly