diff --git a/nn_fingerprint.py b/nn_fingerprint.py index 112ef8c..23f9338 100644 --- a/nn_fingerprint.py +++ b/nn_fingerprint.py @@ -20,8 +20,8 @@ from pathlib import Path from typing import List import torch +import torchaudio import numpy -import resampy import onnxruntime from towhee.operator.base import NNOperator @@ -119,9 +119,11 @@ class NNFingerprint(NNOperator): audio = audio[None, :] assert len(audio.shape) == 2 audio = self.int2float(audio) + audio = torch.from_numpy(audio) if sr != self.params['sample_rate']: - audio = resampy.resample(audio, sr, self.params['sample_rate']) + resampler = torchaudio.transforms.Resample(sr, self.params['sample_rate'], dtype=audio.dtype) + audio = resampler(audio) wav = preprocess_wav(audio, segment_size=int(self.params['sample_rate'] * self.params['segment_size']),