1

I'm loading a file in Python to mess with its audio.
I found the librosa library for that - works great so far, but it takes some time to load the file.
I would like to give a user live feedback on the loading progress so they'll know that nothing's broken.
Anyone know where I can get such a loading progress value from?
Here's my example code:

import time
import librosa

start = time.time()
audio_path = r'C:\Users\....some_music_video_3_min_long.mp4'
audio, sampleRate = librosa.load(audio_path)
end = time.time()
print(f'Elapsed time: {round(end - start, 4)} s')

My output is:

C:\Users\...\venv\lib\site-packages\librosa\core\audio.py:162: 
UserWarning: PySoundFile failed. Trying audioread instead.
warnings.warn("PySoundFile failed. Trying audioread instead.")
Elapsed time: 9.3724 s

My goal output between the warning and the time is something like this:

1%
2%
....
100%
Cold_Class
  • 3,214
  • 4
  • 39
  • 82
  • 1
    This doesn't answer the question, but note that librosa by default will resample audio to 22.05kHz, and this resampling process is slow. You can prevent this by adding `sr=None` to the `load` function, which should speed it up significantly. – xdurch0 Jan 15 '21 at 22:17
  • @xdurch0 wow that just made it load 10 times as fast! So I guess it doesn't answer it, but it does make it almost 'obsolete' which is even better for me - thanks :) I leave this question up here though because who knows, maybe one day I'll be needing this for much bigger files. – Cold_Class Jan 15 '21 at 22:54

0 Answers0