{
  "id": 173488,
  "title": "Dealing with \"PySoundFile failed. Trying audioread instead.\" warning from librosa.load",
  "url": "/competitions/birdsong-recognition/discussion/173488",
  "author_name": "",
  "post_date": "2020-08-09T13:54:56.137744600Z",
  "votes": 2,
  "comment_count": 2,
  "views": 0,
  "content": "<p>Loading an mp3 with <code>librosa</code> with yield this warning, because <code>libsndfile</code> doesn't handle mp3 format.</p>\n<p>The way I see notebooks (in this and other competitions) handling warnings is:</p>\n<pre><code>warnings.filterwarnings(\"ignore\")\n</code></pre>\n<p>Unfortunately, this will also hide any other warning, e.g. deprecation warnings, which may be very useful for you to be aware of.</p>\n<p>It's much better to just silence the one warning that's bothering you, perhaps with a comment on why you need to ignore it - then, your stdout won't be flooded with warnings, and you'll be alerted about any other warnings, e.g.:</p>\n<pre><code>        with warnings.catch_warnings():\n            # libsndfile doesn't handle mp3\n            # see https://github.com/librosa/librosa/issues/1015\n            warnings.simplefilter(\"ignore\", UserWarning)\n            clip, _ = librosa.load(\n                test_audio / (audio_id + \".mp3\"),\n                sr=target_sr,\n                mono=True,\n                res_type=\"kaiser_fast\",\n            )\n</code></pre>",
  "messages": [
    {
      "id": "963995",
      "postDate": "08/09/2020 13:54:56",
      "content": "<p>Loading an mp3 with <code>librosa</code> with yield this warning, because <code>libsndfile</code> doesn't handle mp3 format.</p>\n<p>The way I see notebooks (in this and other competitions) handling warnings is:</p>\n<pre><code>warnings.filterwarnings(\"ignore\")\n</code></pre>\n<p>Unfortunately, this will also hide any other warning, e.g. deprecation warnings, which may be very useful for you to be aware of.</p>\n<p>It's much better to just silence the one warning that's bothering you, perhaps with a comment on why you need to ignore it - then, your stdout won't be flooded with warnings, and you'll be alerted about any other warnings, e.g.:</p>\n<pre><code>        with warnings.catch_warnings():\n            # libsndfile doesn't handle mp3\n            # see https://github.com/librosa/librosa/issues/1015\n            warnings.simplefilter(\"ignore\", UserWarning)\n            clip, _ = librosa.load(\n                test_audio / (audio_id + \".mp3\"),\n                sr=target_sr,\n                mono=True,\n                res_type=\"kaiser_fast\",\n            )\n</code></pre>",
      "rawMarkdown": "Loading an mp3 with `librosa` with yield this warning, because `libsndfile` doesn't handle mp3 format.\n\nThe way I see notebooks (in this and other competitions) handling warnings is:\n```\nwarnings.filterwarnings(\"ignore\")\n```\n\nUnfortunately, this will also hide any other warning, e.g. deprecation warnings, which may be very useful for you to be aware of.\n\nIt's much better to just silence the one warning that's bothering you, perhaps with a comment on why you need to ignore it - then, your stdout won't be flooded with warnings, and you'll be alerted about any other warnings, e.g.:\n\n```python\n        with warnings.catch_warnings():\n            # libsndfile doesn't handle mp3\n            # see https://github.com/librosa/librosa/issues/1015\n            warnings.simplefilter(\"ignore\", UserWarning)\n            clip, _ = librosa.load(\n                test_audio / (audio_id + \".mp3\"),\n                sr=target_sr,\n                mono=True,\n                res_type=\"kaiser_fast\",\n            )\n```",
      "votes": null
    },
    {
      "id": "969181",
      "postDate": "08/13/2020 14:17:43",
      "content": "<p>I think you're better off converting all mp3's to wav files.<br>\nIt'll be a lot faster to load, especially when you convert them to your target sample rate in the process.<br>\nYou can do this with ffmpeg as follows:</p>\n<pre><code>ffmpeg -i $mp3 -ac 1 -ar $sample_rate $wav\n</code></pre>\n<p>where<br>\n<code>$mp3</code> is your mp3 file<br>\n<code>$wav</code> is your wav file<br>\n<code>$sample_rate</code> is the target sample rate<br>\n<code>-ac 1</code> is to make the output mono</p>",
      "rawMarkdown": "I think you're better off converting all mp3's to wav files.\nIt'll be a lot faster to load, especially when you convert them to your target sample rate in the process.\nYou can do this with ffmpeg as follows:\n```\nffmpeg -i $mp3 -ac 1 -ar $sample_rate $wav\n```\nwhere\n`$mp3` is your mp3 file\n`$wav` is your wav file\n`$sample_rate` is the target sample rate\n`-ac 1` is to make the output mono",
      "votes": null
    },
    {
      "id": "969455",
      "postDate": "08/13/2020 17:40:14",
      "content": "<p>cool, didn't know you could do that, thanks!</p>",
      "rawMarkdown": "cool, didn't know you could do that, thanks!",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 969181,
      "author_name": "botkop",
      "author_url": "",
      "post_date": "08/13/2020 14:17:43",
      "content": "<p>I think you're better off converting all mp3's to wav files.<br>\nIt'll be a lot faster to load, especially when you convert them to your target sample rate in the process.<br>\nYou can do this with ffmpeg as follows:</p>\n<pre><code>ffmpeg -i $mp3 -ac 1 -ar $sample_rate $wav\n</code></pre>\n<p>where<br>\n<code>$mp3</code> is your mp3 file<br>\n<code>$wav</code> is your wav file<br>\n<code>$sample_rate</code> is the target sample rate<br>\n<code>-ac 1</code> is to make the output mono</p>",
      "votes": null,
      "replies": [
        {
          "id": 969455,
          "author_name": "marcogorelli",
          "author_url": "",
          "post_date": "08/13/2020 17:40:14",
          "content": "<p>cool, didn't know you could do that, thanks!</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "963995": "Loading an mp3 with `librosa` with yield this warning, because `libsndfile` doesn't handle mp3 format.\n\nThe way I see notebooks (in this and other competitions) handling warnings is:\n```\nwarnings.filterwarnings(\"ignore\")\n```\n\nUnfortunately, this will also hide any other warning, e.g. deprecation warnings, which may be very useful for you to be aware of.\n\nIt's much better to just silence the one warning that's bothering you, perhaps with a comment on why you need to ignore it - then, your stdout won't be flooded with warnings, and you'll be alerted about any other warnings, e.g.:\n\n```python\n        with warnings.catch_warnings():\n            # libsndfile doesn't handle mp3\n            # see https://github.com/librosa/librosa/issues/1015\n            warnings.simplefilter(\"ignore\", UserWarning)\n            clip, _ = librosa.load(\n                test_audio / (audio_id + \".mp3\"),\n                sr=target_sr,\n                mono=True,\n                res_type=\"kaiser_fast\",\n            )\n```",
    "969181": "I think you're better off converting all mp3's to wav files.\nIt'll be a lot faster to load, especially when you convert them to your target sample rate in the process.\nYou can do this with ffmpeg as follows:\n```\nffmpeg -i $mp3 -ac 1 -ar $sample_rate $wav\n```\nwhere\n`$mp3` is your mp3 file\n`$wav` is your wav file\n`$sample_rate` is the target sample rate\n`-ac 1` is to make the output mono",
    "969455": "cool, didn't know you could do that, thanks!"
  },
  "source": "meta"
}