File size: 248 Bytes
4875545 |
1 2 3 4 5 6 7 8 9 10 11 |
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
|