0

I want to load a file from a ZIP file with Librosa's load function.

I already know how to read files from a ZIP using the module ZipFile.

archive = zipfile.ZipFile('audio_data.zip', 'r')
imgfile = archive.open('src_01.wav')

The problem is that Librosa's load function only takes a filepath/filename as its parameter. The following does not work:

y, sr = librosa.load("audio_data.zip/src_01.wav", sr=SR)

Are there any workarounds in loading a compressed file without extracting it?

  • You may want to have a look at this answer : https://stackoverflow.com/a/50202486/5156280 – TGrif Oct 11 '22 at 08:14

1 Answers1

1

You can check the related question here: Download and open file with librosa without writing to filesystem

In short, librosa load can open "file object" or "file-like object", and "a file object can mediate access to a real on-disk file or to another type of storage or communication device (for example standard input/output, in-memory buffers, sockets, pipes, etc.)." https://docs.python.org/3/glossary.html#term-file-object

atoultaro
  • 11
  • 1