librosa.load() takes too long to load(sample) mp3 files


I am trying to sample (convert analog to digital) mp3 files via the following Python code using the librosa library, but it takes too much time (around 4 seconds for one file). I suspect this is because librosa doesn't support mp3 and hence uses the slower audioread to sample mp3


import time import librosa s = time.time() for i in mp3_list[:10]: # list of mp3 file paths, doing for 10 files y, sr = librosa.load(i) print('time taken =', time.time() - s)

time taken = 36.55561399459839

I also get this warning:

UserWarning: "PySoundFile failed. Trying audioread instead."

Obviously, this is too much time for any practical application. I want to know if there are better alternatives to this?

For comparison, it only took around 1.2 seconds total time to sample 10 same-sized wav conversions


So the warning kind of hints it. The Librosa developers addressed a similar question in this GitHub question:


This warning will always occur when loading mp3 because libsndfile does not (yet/currently) support the mp3 format. Librosa tries to use libsndfile first, and if that fails, it will fall back on the audioread package, which is a bit slower and more brittle, but supports more formats.


This is confirmed in the Librosa-code: try ... except RuntimeError ...

So what you can do in this case is either implement your own load() that directly uses audioread to avoid the time wasted in the first block of librosa.load(), or you can use a different library such as pydub. Alternatively, you can use ffmpeg to convert your mp3 to wave before loading them.



  • JWT How to bypass certain API routes and http methods
  • Delphi 2009 using MSBuild in RAD Studio Command Prompt F1026 File not found
  • Java SimpleDateFormat interpret parse-string as UTC
  • Unable to edit ActionBar title from Fragment in ViewPager
  • spring / hibernate - filter by current user id
  • Angular 5 error 404 when copying dist to webserver
  • Linq-to-SQL to search only DATE portions of a date
  • Box shadow not working in microsoft edge
  • invoke-webrequest to get complete web page with images
  • Print a Form at higher dpi than screen resolution
  • search bar getting disappeared in ios UIsearchcontroller
  • Texture streaming in DirectX11, Immutable vs Dynamic
  • Need reference code for SMO in C# SQL Server 2008
  • “RepeatForUnit” item missing in Calendar entry?
  • AngularJS Dynamic Directives inside ng-repeat
  • PySpark: Get first Non-null value of each column in dataframe
  • android 3G signal strength
  • Adding custom message on Thank You page by shipping method
  • Preloading webView doesn't work - trying to reduce loading time
  • UIImage to UIColor array of pixel colors
  • Anaconda + Apache + mod_wsgi + Ubuntu
  • Enable CORS on Tomcat 8.0.30
  • Access to database zend framework
  • Javascript inside HTML import not affecting imported HTML
  • How to add html image in to velocity template file to send email?
  • getting the class name of an HTML tag using XPATH
  • How to create subsets of a single set of elements with XSLT?
  • xpath assertion failure with dynamic xpath
  • how to run a different select statement based on condition in Hive SQL
  • Conflicting declaration using constexpr and auto in C++11
  • How to decleare char *const argv[] in swift [duplicate]
  • How to encrypt Connectionstring written in web.config from codebehind?
  • Can someone explain this Java code (formatting the output using System.out.format) to me?
  • Using Service Component Runtime
  • Firebase: How to read from external DB?
  • What does the “id” field in an Android “Google Play Music” broadcast intent correspond to?
  • convert json to excel in java
  • How to check if object is null in Java?
  • XSLT Transformation to validate rules in XML document