bastibe / python-soundfile

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

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

Closed AmgadHasan closed 3 months ago

AmgadHasan commented 3 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 3 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.