python-3.xpytorchtensortorchaudio

Convert byte data to Pytorch tensor


I created a simple model with Pytorch to recognize bird sounds and until now I feed it .wav recordings. I want to start doing real time recognition and my question is: can I convert bytes to Pytorch tensors directly without converting it first to numpy?

What I do is make an MFCC from the audio that feed it to the model.

Thank you

What I'm doing right now is to use numpy.frombuffer and after I use torch.from_numpy as a way to convert the byte data to tensor


Solution

  • PyTorch also has a torch.frombuffer function.