{
  "id": 44028,
  "title": "Difference between librosa and scipy for data loading",
  "url": "/competitions/tensorflow-speech-recognition-challenge/discussion/44028",
  "author_name": "",
  "post_date": "2017-11-22T13:33:49.564968700Z",
  "votes": 2,
  "comment_count": 4,
  "views": 0,
  "content": "<p>I am trying to understand the difference when loading the same wav file in python using librosa or scipy.\nAs written in the data description, the files are supposed to have a sample rate of 16kHz.</p>\n\n<p>Using librosa:</p>\n\n<pre><code>import librosa\ny, sr = librosa.load(\"train/audio/bed/00176480_nohash_0.wav\")\n</code></pre>\n\n<p>Librosa returns a sample rate \n    sr = 22050</p>\n\n<p>The time series y is an array of float32 with length 22050.</p>\n\n<p>Doing the same with scipy:</p>\n\n<pre><code>import scipy.io.wavfile\nsr, y = wavfile.read(\"train/audio/bed/00176480_nohash_0.wav\")\n</code></pre>\n\n<p>sr = 16000\ny is an array of int16 with length 16000.</p>\n\n<p>Here is a plot of the comparison of the same file.\n<a href=\"https://ibb.co/k4G8L6\">https://ibb.co/k4G8L6</a></p>\n\n<p>Seems that librosa is adding some points in the \"time series\".\nAnybody have some insights about that?</p>",
  "messages": [
    {
      "id": "247172",
      "postDate": "11/22/2017 13:33:49",
      "content": "<p>I am trying to understand the difference when loading the same wav file in python using librosa or scipy.\nAs written in the data description, the files are supposed to have a sample rate of 16kHz.</p>\n\n<p>Using librosa:</p>\n\n<pre><code>import librosa\ny, sr = librosa.load(\"train/audio/bed/00176480_nohash_0.wav\")\n</code></pre>\n\n<p>Librosa returns a sample rate \n    sr = 22050</p>\n\n<p>The time series y is an array of float32 with length 22050.</p>\n\n<p>Doing the same with scipy:</p>\n\n<pre><code>import scipy.io.wavfile\nsr, y = wavfile.read(\"train/audio/bed/00176480_nohash_0.wav\")\n</code></pre>\n\n<p>sr = 16000\ny is an array of int16 with length 16000.</p>\n\n<p>Here is a plot of the comparison of the same file.\n<a href=\"https://ibb.co/k4G8L6\">https://ibb.co/k4G8L6</a></p>\n\n<p>Seems that librosa is adding some points in the \"time series\".\nAnybody have some insights about that?</p>",
      "rawMarkdown": "I am trying to understand the difference when loading the same wav file in python using librosa or scipy.\nAs written in the data description, the files are supposed to have a sample rate of 16kHz.\n\nUsing librosa:\n\n    import librosa\n    y, sr = librosa.load(\"train/audio/bed/00176480_nohash_0.wav\")\n\nLibrosa returns a sample rate \n    sr = 22050\n\nThe time series y is an array of float32 with length 22050.\n\nDoing the same with scipy:\n\n    import scipy.io.wavfile\n    sr, y = wavfile.read(\"train/audio/bed/00176480_nohash_0.wav\")\n\nsr = 16000\ny is an array of int16 with length 16000.\n\nHere is a plot of the comparison of the same file.\nhttps://ibb.co/k4G8L6\n\nSeems that librosa is adding some points in the \"time series\".\nAnybody have some insights about that?",
      "votes": null
    },
    {
      "id": "247178",
      "postDate": "11/22/2017 13:47:01",
      "content": "<p><code>librosa.load()</code> considers a re-sampling rate of 22050 Hz by default, unless you set the <code>sr</code> argument\n<a href=\"https://librosa.github.io/librosa/generated/librosa.core.load.html?highlight=load#librosa.core.load\">https://librosa.github.io/librosa/generated/librosa.core.load.html?highlight=load#librosa.core.load</a></p>\n\n<p>Does it work when you make <code>sr=16000</code> ? Is <a href=\"https://librosa.github.io/librosa/_modules/librosa/core/audio.html?highlight=sr_native#load\"><code>sr_native</code></a> different ?</p>",
      "rawMarkdown": "`librosa.load()` considers a re-sampling rate of 22050 Hz by default, unless you set the `sr` argument\nhttps://librosa.github.io/librosa/generated/librosa.core.load.html?highlight=load#librosa.core.load\n\nDoes it work when you make `sr=16000` ? Is [`sr_native`][1] different ?\n\n\n  [1]: https://librosa.github.io/librosa/_modules/librosa/core/audio.html?highlight=sr_native#load",
      "votes": null
    },
    {
      "id": "247348",
      "postDate": "11/22/2017 21:12:19",
      "content": "<p>Thanks for your reply!\nActually you are right, I somehow completely skept this option in librosa.\nThe two time series are now identical</p>",
      "rawMarkdown": "Thanks for your reply!\nActually you are right, I somehow completely skept this option in librosa.\nThe two time series are now identical",
      "votes": null
    },
    {
      "id": "247350",
      "postDate": "11/22/2017 21:22:00",
      "content": "<p>Hi Jonathan. I have never used librosa, but apparently <code>sr=22050</code> by default instead of <code>None</code> is counter-intuitive for other people too, see <a href=\"https://github.com/librosa/librosa/issues/509\">here</a>. </p>",
      "rawMarkdown": "Hi Jonathan. I have never used librosa, but apparently `sr=22050` by default instead of `None` is counter-intuitive for other people too, see [here][1]. \n\n\n  [1]: https://github.com/librosa/librosa/issues/509",
      "votes": null
    },
    {
      "id": "247506",
      "postDate": "11/23/2017 08:43:50",
      "content": "<p>Hi George. Thanks for your insights! I will probably stick with scipy, which seems also much faster than librosa. Cheers!</p>",
      "rawMarkdown": "Hi George. Thanks for your insights! I will probably stick with scipy, which seems also much faster than librosa. Cheers!",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 247178,
      "author_name": "gsterpu",
      "author_url": "",
      "post_date": "11/22/2017 13:47:01",
      "content": "<p><code>librosa.load()</code> considers a re-sampling rate of 22050 Hz by default, unless you set the <code>sr</code> argument\n<a href=\"https://librosa.github.io/librosa/generated/librosa.core.load.html?highlight=load#librosa.core.load\">https://librosa.github.io/librosa/generated/librosa.core.load.html?highlight=load#librosa.core.load</a></p>\n\n<p>Does it work when you make <code>sr=16000</code> ? Is <a href=\"https://librosa.github.io/librosa/_modules/librosa/core/audio.html?highlight=sr_native#load\"><code>sr_native</code></a> different ?</p>",
      "votes": null,
      "replies": [
        {
          "id": 247348,
          "author_name": "jobrown",
          "author_url": "",
          "post_date": "11/22/2017 21:12:19",
          "content": "<p>Thanks for your reply!\nActually you are right, I somehow completely skept this option in librosa.\nThe two time series are now identical</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 247350,
          "author_name": "gsterpu",
          "author_url": "",
          "post_date": "11/22/2017 21:22:00",
          "content": "<p>Hi Jonathan. I have never used librosa, but apparently <code>sr=22050</code> by default instead of <code>None</code> is counter-intuitive for other people too, see <a href=\"https://github.com/librosa/librosa/issues/509\">here</a>. </p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 247506,
          "author_name": "jobrown",
          "author_url": "",
          "post_date": "11/23/2017 08:43:50",
          "content": "<p>Hi George. Thanks for your insights! I will probably stick with scipy, which seems also much faster than librosa. Cheers!</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "247172": "I am trying to understand the difference when loading the same wav file in python using librosa or scipy.\nAs written in the data description, the files are supposed to have a sample rate of 16kHz.\n\nUsing librosa:\n\n    import librosa\n    y, sr = librosa.load(\"train/audio/bed/00176480_nohash_0.wav\")\n\nLibrosa returns a sample rate \n    sr = 22050\n\nThe time series y is an array of float32 with length 22050.\n\nDoing the same with scipy:\n\n    import scipy.io.wavfile\n    sr, y = wavfile.read(\"train/audio/bed/00176480_nohash_0.wav\")\n\nsr = 16000\ny is an array of int16 with length 16000.\n\nHere is a plot of the comparison of the same file.\nhttps://ibb.co/k4G8L6\n\nSeems that librosa is adding some points in the \"time series\".\nAnybody have some insights about that?",
    "247178": "`librosa.load()` considers a re-sampling rate of 22050 Hz by default, unless you set the `sr` argument\nhttps://librosa.github.io/librosa/generated/librosa.core.load.html?highlight=load#librosa.core.load\n\nDoes it work when you make `sr=16000` ? Is [`sr_native`][1] different ?\n\n\n  [1]: https://librosa.github.io/librosa/_modules/librosa/core/audio.html?highlight=sr_native#load",
    "247348": "Thanks for your reply!\nActually you are right, I somehow completely skept this option in librosa.\nThe two time series are now identical",
    "247350": "Hi Jonathan. I have never used librosa, but apparently `sr=22050` by default instead of `None` is counter-intuitive for other people too, see [here][1]. \n\n\n  [1]: https://github.com/librosa/librosa/issues/509",
    "247506": "Hi George. Thanks for your insights! I will probably stick with scipy, which seems also much faster than librosa. Cheers!"
  },
  "source": "meta"
}