When we are using python librosa to read an audio, we may get this error: NoBackendError. In this tutorial, we will introduce you how to fix it.
This error looks like:
How to fix this error?
We can read this audio using soundfile or scipy.io.wavfile.read().
Here are two tutorials:
Then, we can save audio data to pcm and read it by librosa again.
Here is an solution.
import librosa import soundfile as sf def save_file(audio_data, wave_file, sr = 8000): sf.write(wave_file, audio_data, sr, 'PCM_16') file = "test.mp3" try: data, sr = librosa.load(file, sr = 8000, mono=True) except Exception as e: audio_data, samplerate = sf.read(file, dtype="float32") save_file(audio_data, file, sr = samplerate )
In this solution, we read test.mp3 file using soundfile, then save it to new format.
Finally, we can use librosa to read test.mp3 successfully.