From 1a64d017b76907aacb3d088f66e75e76d0f51c92 Mon Sep 17 00:00:00 2001 From: shahules786 Date: Tue, 6 Sep 2022 20:44:42 +0530 Subject: [PATCH] torch resample --- enhancer/utils/io.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/enhancer/utils/io.py b/enhancer/utils/io.py index be59e73..023a57c 100644 --- a/enhancer/utils/io.py +++ b/enhancer/utils/io.py @@ -4,6 +4,7 @@ from typing import Optional from matplotlib.pyplot import axis import numpy as np import torch +import torchaudio class Audio: @@ -68,4 +69,15 @@ class Audio: if sr!=target_sr: audio = librosa.resample(audio,orig_sr=sr,target_sr=target_sr) + return audio + + @staticmethod + def pt_resample_audio( + audio, + sr:int, + target_sr:int + ): + if sr!=target_sr: + audio = torchaudio.functional.resample(audio,orig_freq=sr,new_freq=target_sr) + return audio \ No newline at end of file