i'm trying to use librosa to generate some data by cutting 1s pieces from some .wav file with a duration of 60s.
This part works, i create all my files and i can also listen to them via any player, but if i try to open them with librosa.load i receive this error:
>>> librosa.load('.\\train\\audio\\silence\\0doing_the_dishes.wav', sr=None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\gionata\AppData\Local\Programs\Python\Python36\lib\site\packages\librosa\core\audio.py", line 107, in load
with audioread.audio_open(os.path.realpath(path)) as input_file: File "C:\Users\gionata\AppData\Local\Programs\Python\Python36\lib\site-packages\audioread\__init__.py", line 116, in audio_open
raise NoBackendError()
audioread.NoBackendError
Do you have any suggestion? I create the file.wav with this function:
def create_silence():
path=DB+"_background_noise_/"
sounds = [x[len(DB):] for x in glob.glob(path+ '*.wav')]
for elem in enumerate(sounds):
sound=elem.split('\\')[1]
print(sound)
for j,i in enumerate(np.arange(0.0, 59.0, 0.3)):
y, sr=librosa.load(DB+elem, sr=None, offset=i, duration=1.0)
librosa.output.write_wav(DB+'silence/'+str(j)+sound, y, sr=sr, norm=False)
The problem only presents itself with file created by librosa, librosa.load has worked with other files with no problems at all.
It's about ffmpeg, if you use windows, you can solve this according to here and if you use linux, if can try:
I couldn't get 吴连伟's or Gionata's solution to work, however this did the trick:
(Where path is the path and file name, y is the first output from librosa.load, and sr the second output from librosa.load)
This wav-file I could load with librosa in a later stage, so it solved the problem!
It have worked for me xf=array of sound file,sr=frequency
libav-tools is deprecated in ubuntu, so
did the trick
I solvede this, Librosa outputs the values as they are, in my case the np.array where float32 but the standard is 16 bit for each value, so changing the type does the trick: