1

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

0

2 Answers 2

0

PyTorch also has a torch.frombuffer function.

Sign up to request clarification or add additional context in comments.

Comments

0

there has more flexible and effcient way:

import numpy
import torch
resut=torch.Tensor(numpy.frombuffer(bytes_origin_var, dtype=numpy.int32))

where result is dtypet is numpy.int32 tensor

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.