logo
Browse Source

Replace resampy with torchaudio

Signed-off-by: Jael Gu <mengjia.gu@zilliz.com>
main
Jael Gu 2 years ago
parent
commit
7c1f303582
  1. 6
      nn_fingerprint.py

6
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']),

Loading…
Cancel
Save