0

I have been trying to create mfcc of every file in my dataset. I want to create a preprocessing fuction which takes the source_path as input and returns dictionary mydict with two keys label , mfcc.

I have tried to create the following function

def preprocess_data(source_path):
    
    mydict = {
        "labels" : [] ,
         "mfcc" : []  
          }
    
    music = ['reggae', 'jazz', 'country', 'hiphop', 'rock', 'metal', 'classical', 'disco', 'blues', 'pop']
    path = 'Data/genres_original/'
    i = 0 
    for n in music : 
       new_path = path + n
       song = os.listdir(new_path) 
       for p in song:
            final_path = new_path + "/" + p
            
            melody , sr = librosa.load(final_path)
         
            mfcc = librosa.feature.mfcc(melody, sr=sr, n_mfcc=13)
                 
            mydict["labels"].append(i)
            mydict["mfcc"].append(mfcc.tolist()) 
       i+= 1 
   
    return mydict

but this is not working intead it shows a warning PySoundFile failed. Trying audioread instead. and then gives error ! to resolve it have also installed ffmpeg but it didn't do anything

note : i am using google colab and expect a code that runs on it here is the link

sam
  • 7
  • 2

0 Answers0