Can't load audio files with librosa - python

Unless I use one of librosa's native 'example' audio files which are in some format '.ogg', I cannot load audio.
Every github issue and SO answer says I need to install ffmpeg. I found a python package called ffmpeg and installed it into my virtual environment. I also found some sort of multi-purpose program called ffmpeg and installed it onto my Windows machine, and added it's location to my PATH variable.
I still get the same warnings and errors that everyone else is getting:
c:\users\wesle\appdata\local\programs\python\python38\lib\site-packages\librosa\core\audio.py:162: UserWarning: PySoundFile failed. Trying audioread instead.
warnings.warn("PySoundFile failed. Trying audioread instead.")
---------------------------------------------------------------------------
.
.
.
115 # All backends failed!
--> 116 raise NoBackendError()
I can find no resolution for this problem despite the number of people asking for help on it.

I don't know what fileformat you are trying to load, but in most cases installing ffmpeg is the solution to this problem. It is important to add the "../bin/" directory to PATH and restart the environment. Using the "set" command from prompt you can check that the current path contains the folder.

Related

Have difficulty to solve "No module named pkg_resources"

Hope someone can help me! I appreciate it.
I tried to download some open source from GitHub, but it shows "No module named pkg_resources".
Then I searched some solution from No module named pkg_resources , but it showed the error below. I also found some solution from other articles, but it still not working.
Installing Setuptools
running install
error: can't create or remove files in install directory
The following error occurred while trying to add or remove files in the
installation directory:
[Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/test-easy-install-48274.write-test'
The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/
Perhaps your account does not have write access to this directory? If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account. If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.
For information on other options, you may wish to consult the
documentation at:
https://setuptools.readthedocs.io/en/latest/easy_install.html
Please make the appropriate changes for your system and try again.
Something went wrong during the installation.
See the error message above.
p.s. I couldn't open that link in the error messages https://setuptools.readthedocs.io/en/latest/easy_install.html.
By the way, I've checked my pip version and it also showed "No module named pkg_resources". I'm confused because I use Python for like 1-2 years, and everything goes fine, but I just found this error message today. If I couldn't solve this problem, it might be a huge trouble because I can't download everything about "Pip".
Probably the easiest solution would be to download get-pip.py, then run it using sudo:
sudo python3 get-pip.py
assuming you have admin permissions on your computer. easy_install has been deprecated for a long time, and pip is definitely the way to go. By reinstalling pip, setuptools and all its dependencies should be correctly installed as well.

OCRmyPDF throws [WinError 2] The system cannot find the file specified

I've got a strange error: as soon as I run OCRmyPDF (inside Python or cmd), my output is stuffed with the following error message:
[WinError 2] The system cannot find the file specified
Even through the "verbosity=True" option in the logger, I get no indication of the origin of the error message (I get this error already when I only import the library). Also, the function does exactly what it is supposed to do and the process completes with exit code 0.
Does anybody know, what could be wrong there?
Best,
Kevin
Please follow the following two steps
Install camelot-py from https://pypi.org/project/camelot-py/.
Then after install Ghostscript from https://www.ghostscript.com/download/gsdnld.html and add in environment variables.
NOTE: Add the following path in computer environment variables
C:\Program Files\gs\gs9.54.0\bin
C:\Program Files\gs\gs9.54.0\lib
Then after restart your computer, then problem fixed.
NOTE: But if you still face an error, make sure you have install ocrmypdf version 12.2.o by command. pip install ocrmypdf==12.2.0
Thank you
The OCRMyPDF library depends heavily on some packages that are not available on windows by default. Tesseract (https://tesseract-ocr.github.io/tessdoc/), GhostScript (https://www.ghostscript.com/) and Unpaper for instance. You need to ensure they are installed and available in your path. Using a package manager like chocolatey can make getting these packages installed a straightforward process.

I have pip installed pydub but still didn't work

After I had pip installed pydub and SpeechRecognition, I still can't make the program run successfully although I extracted the files from ffmpeg and specified the folder name bin in the corresponding directory. I tried to find solutions to solve the problem but it sill didn't work after I followed the steps clearly from the web. May I ask what is the good way to read .wav files using pydub AudioSegment?
Warning (from warnings module):
File "C:\Python38\lib\site-packages\pydub\utils.py", line 171
warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
Make sure that you have ffmpeg http://www.ffmpeg.org/ installed. You can get help from this official page.
Other thing that I can think of is that ffmpeg is installed and is in your path but not in the path of the process using pydub.
If this is the reason for the error, then you can set the absolute path to ffmpeg directly like shown below:
import pydub
pydub.AudioSegment.ffmpeg = "/absolute/path/to/ffmpeg"
sound = AudioSegment.from_mp3("test.mp3")
Give this a try.

Python install issue

Totally new to Python (some basic HTML in secondary school) but as part of a Maths degree we are required to use Python and specifically Anaconda.
I have attempted to install it on my Windows 7 laptop and it has not gone well. Opening Anaconda prompt returns :" 'C:\ProgramData\Anaconda2\Scripts\activate.bat' is not recognised as an internal or external command, operable program or batch file. "
A google search recommended going into the file directory but using where Anaconda (both capitalised and not) returns "INFO: Could not find files for the given pattern(s).". I can't find it in either Program Files folder, or any where else. Also should mention I did not tick the option to create a new PATH during installation as the wizard recommended against it, and I cannot reinstall as every time it says "Error 'Destination Folder' contains 2 spaces. This can cause problems with several Conda packages, and is thus disabled. Please install to a path without the spaces.".
Finally, the version I am trying to install is Anaconda 2 5.0.0 as recommended by the tutor.
Many thanks.
Try uninstalling Anaconda, then reinstall from here. Or if you have previously installed Python on your computer separately then uninstall it and during the Anaconda installation it be reinstalled for you.
Error 'Destination Folder' contains 2 spaces. This can cause problems with several Conda packages and is thus disabled. Please install to a path without the spaces.
To overcome this error, rename your file but keep in mind that there can't be any space in it.

No module named itk (Insighttolkit) in Python

I am novice in python and Simple_ITK both to process .mha 3D image files. I have two problems:
When ever I install ITK, I always get an error as shown below:
and somehow I install ITK It doesn't work at all having no connectivity with python. And I also tried python-insighttoolkit3 package then it shows and error of
" Can't down load Python 2.8:i386" in Ubuntu software Center. I have tried various methods to install Insight Tool Kit in Ubuntu whatever I found but most of the time I get the same error as shown in picture above.
So can anybody guide me how to install and build ITK so that no error like no module named itk found.
Now another problem is I have a .py file and it has a class in which I have to fed input externally otherwise it will consider as None. SO I tried to call the file as
import /path/to/file/xxx.py
but it gives an Syntax error: invalid syntax
so how to call class from a python file from python Console .
Now, I'm using Ubuntu 15.02. For any missing details please ask.
Thanks.
1- For what I see in the image, I see that you are trying to install ITK instead of SimpleITK. For SimpleITK it is very simple using a linux package installer, like pip or easy-install. in this link you have the instructions to install it correctly. Remember to execute the instructions as super user. Maybe it is the reason of your error ( I can't see the instruction you are writing in the console ).
2- I recommend you to read the Python tutorial for modules The fastest way is to be located first on the directory of your .py file. The sequence would be:
cd /path
import module.py

Categories

Resources