I want to read multiple audio files with librosa and then save it into an empty list

2024/11/19 8:48:30

Here id my code . when I append into the array the array remain empty . Please help me where is the mistake. Or tell me some other way also to do this

A = [] 
# load more files with librosa
pathAudio = "drive/My Drive/dataset/noise/"
files = librosa.util.find_files(pathAudio, ext=['wav']) 
files = np.asarray(files)
for y in files: data, sr = librosa.load(y)ps = librosa.feature.melspectrogram(y= data, sr=sr)   if ps.shape != (128, 128): continueA.append((ps, y.files))

I checked the ps.shape the output was (128,427). I think it has to save in that array

I also checked y.files the output was *** AttributeError: 'numpy.str_' object has no attribute 'files'

Answer

The initial guess is that the shape of the MEL weighted spectrogram is not (128,128).

But the question is really really really really not giving any relevant information in order for someone to understand what is happening. For example, are all files of same duration? Then, what is the duration of the files?

https://en.xdnf.cn/q/119967.html

Related Q&A

How to db.execute in postgresql using the LIKE operator with variables within flask [duplicate]

This question already has an answer here:CS50: LIKE operator, variable substitution with % expansion(1 answer)Closed 4 years ago.Im trying to get my db.execute to work but encounter a syntax error when…

C, Perl, and Python similar loops different results

I wrote scripts to calculate pi in python, perl and c. They all use the same algorithm (trapezoidal reimann sum of a circle with n subintervals) and the python and perl programs always get the same re…

How to print a single backslash in python in a string? [duplicate]

This question already has answers here:Why do backslashes appear twice?(2 answers)Closed 1 year ago.In python (3x version)\ # this is error no doubt \\ # this prints two backslashes ,i.e., \\ r\ # thi…

Return nested JSON item that has multiple instances

So i am able to return almost all data, except i am not able to capture something like this:"expand": "schema""issues": [{"expand": "<>","id…

What request should I make to get the followers list from a specific profile page

I am trying to get the followers list from this profile, I tried making a GET request using python requests to the API using this request URL but it didnt seem to work, I got a METHOD_NOT_ALLOWED error…

PlayerDB API Post Requests bring 404

I made a little script to get the UUIDs of people who joined my minecraft server, then run them through the PlayerDB API through a post request to: https://playerdb.co/api/player/minecraft/* where the …

How to make changes using Configparser in .ini file persistent

How to modify the .ini file? My ini file looks like this. And i want the format section ini to be changed like this[Space to be replaced with a tab followed by $] Format="[%TimeStamp%] $(%Thre…

How to structure template libraries in a Django project? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.Clo…

Not able to click button with Selenium (Python)

Im trying to click a button using Selenium, but everytime I get the message that it cant find the element. This happens even when I put a time.sleep() in front of it. time.sleep(5)#Click on downloaddow…

how to aproximate shapes height and width for image detection using opencv and python

i was following a tutorial about shapes detection using opencv ,numpy and python ,and it was this function i know the reason from it but i do not know how to modify it so i can use it as i want the to…