Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch NoBackendError exception and tell user to install ffmpeg #446

Closed
ghost opened this issue Jul 24, 2020 · 2 comments
Closed

Catch NoBackendError exception and tell user to install ffmpeg #446

ghost opened this issue Jul 24, 2020 · 2 comments
Labels
good first issue Good for newcomers

Comments

@ghost
Copy link

ghost commented Jul 24, 2020

Despite instructions to install ffmpeg in README.md (#414), people still skip it and get audioread's NoBackendError whenever trying to load mp3s. The exception is confusing to the end user and we get a lot of questions about it.

Here are some options for dealing with it, sorted in ascending order of preference.

Option 1: Catch it when it occurs

This would make a nice starter issue for someone who is just getting started with python:

In demo_cli.py and demo_toolbox.py,

  1. Use try/except around librosa.load()
  2. Catch the NoBackendError exception (this will require you to import NoBackendError from audioread.exceptions)
  3. Print a helpful error message instructing the user to install ffmpeg for mp3 support.

Option 2: Test for mp3 support as toolbox is loaded

This is a little more advanced, but I think this is preferred.

  1. As the toolbox is opened, or when demo_cli.py is started, we either use librosa.load() or audioread.audio_open() on a sample mp3 file to test the capability.
  2. If we catch NoBackendError we nag the user and tell them to either install ffmpeg, or rerun the toolbox with --no_mp3_support
  3. The --no_mp3_support flag disallows loading of mp3s when one is selected, preventing NoBackendError from being encountered.

Option 3: Check for ffmpeg backend as toolbox is loaded

Although other backends are able to open mp3, we can force a check for Windows users to see if they followed the instructions and installed ffmpeg. Then do the same nag as option 2 if not detected.

audioread.ffdec.available() can test for ffmpeg availability: audioread/ffdec.py

Take a look at audioread/__init__.py and see how it raises NoBackendError. The code is extremely simple.

Option 4: Contribute to audioread to make the error message more descriptive

beetbox/audioread#104

@ghost
Copy link
Author

ghost commented Sep 3, 2020

This is resolved by #517. Thank you for the contribution @ramalamadingdong .

@ghost ghost closed this as completed Sep 3, 2020
@ramalamadingdong
Copy link
Contributor

Thanks for the support!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant