safe-example-submission / preprocess.py
kt-test-account's picture
updates
4875545
raw
history blame contribute delete
248 Bytes
import librosa
import torch
def preprocess(audio_file):
# Load the audio file
y, sr = librosa.load(audio_file, sr=None)
mfccs = librosa.feature.mfcc(y=y, sr=sr, n_mfcc=13)
tensor = torch.from_numpy(mfccs)[None]
return tensor