Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

librosa can't open .wav created by librosa?

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.

like image 511
Gionata Benelli Avatar asked Jan 04 '23 01:01

Gionata Benelli


1 Answers

It's about ffmpeg, if you use windows, you can solve this according to here and if you use linux, if can try:

sudo apt-get install libav-tools
like image 192
renewu Avatar answered Jan 05 '23 14:01

renewu