Reading Mp3 files from S3 to Sagemaker for feature extraction using LIBROSA

Viewed 16

Hi I am trying to load mp3 files which are stored in S3 to Sage maker for audio feature extraction using Librosa!

Initially I get all the mp3 files paths

def get_all_files():
    files = []
    #initiate s3 resource
    s3 = boto3.resource('s3')
    # select bucket
    my_bucket = s3.Bucket('songs')
    # download file into current directory
    for s3_object in my_bucket.objects.filter(Prefix = 'c/songs/'):
        if s3_object.key.endswith('mp3'):
            filename = s3_object.key
            print(filename)
            files.append(filename)

mp3 file paths

Then tried to download files using below function

def download_all_files_music():
    #initiate s3 resource
    s3 = boto3.resource('s3')
    # select bucket
    my_bucket = s3.Bucket('songs')
    # download file into current directory
    for s3_object in my_bucket.objects.filter(Prefix = 'c/songs/'):
      if s3_object.key.endswith('mp3'):
        filename = s3_object.key
        print(filename)
        my_bucket.download_file(s3_object.key, filename)

But I am getting this error!

file not found error

Do I need to make all the songs publicly accessible to load using boto?

0 Answers
Related