Supress "PySoundFile failed. Trying audioread instead." warning

See original GitHub issue

I’m trying to load an mp3 file with librosa.load(path) and it returns the following warning:

>>> import librosa
>>> librosa.load('mysong.mp3')
/data/anaconda3/envs/aidio/lib/python3.7/site-packages/librosa/core/audio.py:146: UserWarning: PySoundFile failed. Trying audioread instead.
  warnings.warn('PySoundFile failed. Trying audioread instead.')
(array([-0.00183699, -0.00195219,  0.00391953, ..., -0.00337326,
        0.00295902,  0.00624093], dtype=float32), 22050)

As I’m doing this multiple times it floods the stdout. So I have some questions:

  1. Why is this a warning? Does it imply something bad?
  2. Can I hide this warning text? As it floods my stdout in my batch operations.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:20
  • Comments:17 (8 by maintainers)

github_iconTop GitHub Comments

36reactions
bmcfeecommented, Nov 11, 2019
1. Why is this a warning? Does it imply something bad?

It’s a warning, not an error. This warning will always occur when loading mp3 because libsndfile does not (yet/currently) support the mp3 format. Librosa tries to use libsndfile first, and if that fails, it will fall back on the audioread package, which is a bit slower and more brittle, but supports more formats.

2\. Can I hide this warning text? As it floods my stdout in my batch operations.

Yes, you can always filter warnings. https://docs.python.org/3/library/warnings.html

16reactions
Vichokocommented, Jan 15, 2020

Any idea how to avoid getting this warnings printed on STDOUT?

I tried launching script with python -W ignore <script> and adding:

import warnings
warnings.filterwarnings('ignore')

At the beginning of the scripts and this User Warnings keep poping out.

Edit: Nevermind it was my issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PySoundFile failed. Trying audioread instead. - Google Groups
This warning is easy enough to ignore, but I'm trying to understand why it exists in the first place. From my perspective the...
Read more >
Can´t use librosa with python 3 - Stack Overflow
/home/henistein/librosa/librosa/core/audio.py:144: UserWarning: PySoundFile failed. Trying audioread instead. warnings.warn('PySoundFile ...
Read more >
Troubleshooting — librosa 0.10.0.dev0 documentation
UserWarning: PySoundFile failed. Trying audioread instead. Do not worry. This is a warning, not an error. Odds are that your code is working...
Read more >
VGAF-finetune | Kaggle
Trying audioread instead. return f(*args, ... UserWarning: PySoundFile failed. ... instead, or set `no_deprecation_warning=True` to disable this warning ...
Read more >
Librosa.load() takes too long to load(sample) mp3 files
I am trying to sample (convert analog to digital) mp3 files via the following Python code ... UserWarning: "PySoundFile failed. Trying audioread instead."....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found