bastibe / python-soundfile

SoundFile is an audio library based on libsndfile, CFFI, and NumPy
BSD 3-Clause "New" or "Revised" License
717 stars 111 forks source link

REQUEST: Allow resampling when loading non-raw files #437

Closed AmgadHasan closed 4 months ago

AmgadHasan commented 4 months ago

Currently, if you try to read a non-raw audio file (e.g. mp3) and resample it, it will give the following error:

>>> librosa.load("audio.mp3", sr=16000)
TypeError: Not allowed for existing files (except 'RAW'): samplerate, channels, format, subtype, endian

This is a really frustrating user experience.

I am creating this issue to request a feature that will allow the user to specify the target samplerate even for non-raw audio files.

Thanks!

bastibe commented 4 months ago

Please use resampy if you need resampling. Soundfile is a library for reading and writing files, no more, no less.

If you need this feature in librosa, open an issue in librosa. It may suit their use case.