{
  "id": 429335,
  "title": "always failed to load audio by torchaudio when GPU is enabled",
  "url": "/competitions/bengaliai-speech/discussion/429335",
  "author_name": "",
  "post_date": "2023-08-05T05:50:09.675490100Z",
  "votes": 2,
  "comment_count": 2,
  "views": 0,
  "content": "<p>import torchaudio<br>\nx, sr = torchaudio.load('/kaggle/input/bengaliai-speech/train_mp3s/000005f3362c.mp3', format='mp3')</p>\n<p>If GPU is enabled, this line of code will cause Runtime error.  CPU mode is ok.</p>",
  "messages": [
    {
      "id": "2374610",
      "postDate": "08/05/2023 05:50:09",
      "content": "<p>import torchaudio<br>\nx, sr = torchaudio.load('/kaggle/input/bengaliai-speech/train_mp3s/000005f3362c.mp3', format='mp3')</p>\n<p>If GPU is enabled, this line of code will cause Runtime error.  CPU mode is ok.</p>",
      "rawMarkdown": "import torchaudio\nx, sr = torchaudio.load('/kaggle/input/bengaliai-speech/train_mp3s/000005f3362c.mp3', format='mp3')\n\nIf GPU is enabled, this line of code will cause Runtime error.  CPU mode is ok.",
      "votes": null
    },
    {
      "id": "2374662",
      "postDate": "08/05/2023 06:25:49",
      "content": "<p>I encountered the same problem. It seems that there are some conflicts between ffmpeg and torchaudio when dealing with mp3 files. I just switch to librosa. </p>",
      "rawMarkdown": "I encountered the same problem. It seems that there are some conflicts between ffmpeg and torchaudio when dealing with mp3 files. I just switch to librosa.",
      "votes": null
    },
    {
      "id": "2374704",
      "postDate": "08/05/2023 07:11:40",
      "content": "<p>i think latest version of torchaudio don't read mp3 file.<br>\ncheck the torchaudio documentation.</p>\n<p>use this insetad</p>\n<pre><code> transformers.pipelines.audio_utils import ffmpeg_read\n\ndef read_audio(audio_file, sampling_rate):\n     (audio_file, )  f:\n        bpayload = f.()\n     = ffmpeg_read( bpayload , sampling_rate)\n     \n</code></pre>",
      "rawMarkdown": "i think latest version of torchaudio don't read mp3 file.\ncheck the torchaudio documentation.\n\nuse this insetad\n\n```\n\nfrom transformers.pipelines.audio_utils import ffmpeg_read\n\ndef read_audio(audio_file, sampling_rate):\n\twith open(audio_file, 'rb') as f:\n\t\tbpayload = f.read()\n\ta = ffmpeg_read( bpayload , sampling_rate)\n\treturn a\n\n\n```",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 2374662,
      "author_name": "aphysict",
      "author_url": "",
      "post_date": "08/05/2023 06:25:49",
      "content": "<p>I encountered the same problem. It seems that there are some conflicts between ffmpeg and torchaudio when dealing with mp3 files. I just switch to librosa. </p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 2374704,
      "author_name": "hengck23",
      "author_url": "",
      "post_date": "08/05/2023 07:11:40",
      "content": "<p>i think latest version of torchaudio don't read mp3 file.<br>\ncheck the torchaudio documentation.</p>\n<p>use this insetad</p>\n<pre><code> transformers.pipelines.audio_utils import ffmpeg_read\n\ndef read_audio(audio_file, sampling_rate):\n     (audio_file, )  f:\n        bpayload = f.()\n     = ffmpeg_read( bpayload , sampling_rate)\n     \n</code></pre>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "2374610": "import torchaudio\nx, sr = torchaudio.load('/kaggle/input/bengaliai-speech/train_mp3s/000005f3362c.mp3', format='mp3')\n\nIf GPU is enabled, this line of code will cause Runtime error.  CPU mode is ok.",
    "2374662": "I encountered the same problem. It seems that there are some conflicts between ffmpeg and torchaudio when dealing with mp3 files. I just switch to librosa.",
    "2374704": "i think latest version of torchaudio don't read mp3 file.\ncheck the torchaudio documentation.\n\nuse this insetad\n\n```\n\nfrom transformers.pipelines.audio_utils import ffmpeg_read\n\ndef read_audio(audio_file, sampling_rate):\n\twith open(audio_file, 'rb') as f:\n\t\tbpayload = f.read()\n\ta = ffmpeg_read( bpayload , sampling_rate)\n\treturn a\n\n\n```"
  },
  "source": "meta"
}