2

I'm new to torch audio and i'm following the this tutorial step by step. I'm having a problem loading an mp3 audio using torchaudio.info(path).

Here is my code:

metadata = torchaudio.info(SAMPLE_MP3_PATH)
print(metadata)

Here is the error that i'm getting:

..

RuntimeError: Error opening '_sample_data\\steam.mp3': File contains data in an unknown format.
  • torch: v1.9.1+cpu
  • torchaudio: v0.9.1
crispengari
  • 7,901
  • 7
  • 45
  • 53
  • I am quite unfamilier with audio stuff but [the docs](https://pytorch.org/audio/stable/backend.html#torchaudio.backend.sox_io_backend.info) suggest there is a `format=` argument to `.info()` function. Ca you try passing `format='mp3'`? – ayandas Oct 13 '21 at 10:47
  • Facing the same problem, the code seems to work for only .wav format and gives the error for .mp3 and .gsm. Also, my touch audio backend is Soundfile. Is any solution available? – FrozenWolf Feb 16 '22 at 02:12

1 Answers1

1

torchaudio.info will call its backend to show the information. If you use it in windows, and the backend is Soundfile, then this problem will occur. Because Soundfile does not support mp3 format. You can use the below code to see the available formats.

import soundfile as sf
sf.available_formats()
ouflak
  • 2,458
  • 10
  • 44
  • 49
BugMaker
  • 21
  • 5