2

I am trying to perform STFT on a bunch of sound files and I get this error. The path of the files which I am trying to perform STFT is correct but still, I get this error.

import librosa
import io
import numpy as np
import tensorflow as tf
import os
import glob


path_te = "C:\Users\aanum\OneDrive\Documents\Deep Learning\timit-homework\te"
files = os.listdir(path_te)
for file in sorted(files):
    if file.startswith("tex"):

        file_path = path_te2 + "/" + file 

        #file_path = 'r' + "'" + str(file_path) + "'"
        print(file_path)
        st, sr=librosa.load(file_path, sr=None)

Output:

C:/Users/aanum/OneDrive/Documents/Deep Learning/timit-homework/te/tex0000.wav
---------------------------------------------------------------------------
NoBackendError                            Traceback (most recent call last)
<ipython-input-54-4df25548d204> in <module>
      7         #file_path = 'r' + "'" + str(file_path) + "'"
      8         print(file_path)
----> 9         st, sr=librosa.load(file_path, sr=None)
     10         X=librosa.stft(st, n_fft=1024, hop_length=512)
     11         X_abs = abs(X)

~\Anaconda3\envs\DeepLearning\lib\site-packages\librosa\core\audio.py in load(path, sr, mono, offset, duration, dtype, res_type)
    117 
    118     y = []
--> 119     with audioread.audio_open(os.path.realpath(path)) as input_file:
    120         sr_native = input_file.samplerate
    121         n_channels = input_file.channels

~\Anaconda3\envs\DeepLearning\lib\site-packages\audioread\__init__.py in audio_open(path, backends)
    114 
    115     # All backends failed!
--> 116     raise NoBackendError()

NoBackendError

Can anyone tell me why I have this error?

agastya teja
  • 629
  • 2
  • 9
  • 18
  • Sounds like a librosa installation issue. I'd try re-installing librosa, `conda config --add channels conda-forge` and `conda install librosa`. – Hendrik Nov 12 '19 at 09:46
  • This worked for me. I also had to install ffmpeg.. this https://www.wikihow.com/Install-FFmpeg-on-Windows had been some help in it – Suraj Jeswara Sep 19 '20 at 08:03

3 Answers3

3

Make sure that your .wav file is not corrupted. Can you open the file with an audio file reader (which can read wav files)? If not, your file is corrupted. If you downloaded the audio files from an opensource dataset, it is possible that they are corrupted while you are manually unzipping the folder. I'd recommend you download the dataset again and unzip it with a command-line tool.

Josmy
  • 408
  • 3
  • 12
  • Thanks, I have the problem with **unzipping the folder** that makes librosa can ONLY load files size under 1MB – herbertD Apr 21 '21 at 08:33
2

This error can occur when Librosa cannot load the file, mainly because librosa cannot read the file format (for example mp3 format) and it tries to look for other backends like ffmpeg. So, installing ffmpeg may help in resolving this problem. Also, depending on the OS you use, you may have to add ffmpeg to the OS path in some cases. If the issue is in fact due to the file format, proper installation of ffmpeg may resolve the issue.

SAN
  • 75
  • 2
  • 11
  • In the question output, it is mentioned that the file is wav format. But No backed error usually comes when it is not able to load the file. – Abhishek Sep 10 '20 at 17:28
1

Right after you write the line:

import usb.core 

you need to write

import usb.backend.libusb1

I hope this helped you, tell me if it doesn't work!

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
KingIdea
  • 11
  • 1