Skip to main content

Music2Latent

Encode and decode audio samples to/from compressed representations! Useful for efficient generative modelling applications and for other downstream tasks.

music2latent

Read the ISMIR 2024 paper here. Listen to audio samples here.

Under the hood, Music2Latent uses a Consistency Autoencoder model to efficiently encode and decode audio samples.

44.1 kHz audio is encoded into a sequence of ~10 Hz, and each of the latents has 64 channels. 48 kHz audio can also be encoded, which results in a sequence of ~12 Hz. A generative model can then be trained on these embeddings, or they can be used for other downstream tasks.

Music2Latent was trained on music and on speech. Refer to the paper for more details.

Installation

pip install music2latent

The model weights will be downloaded automatically the first time the code is run.

How to use

To encode and decode audio samples to/from latent embeddings:

audio_path = librosa.example('trumpet')
wv, sr = librosa.load(audio_path, sr=44100)

from music2latent import EncoderDecoder
encdec = EncoderDecoder()

latent = encdec.encode(wv)
# latent has shape (batch_size/audio_channels, dim (64), sequence_length)

wv_rec = encdec.decode(latent)

To extract encoder features to use in downstream tasks:

features = encoder.encode(wv, extract_features=True)

These features are extracted before the encoder bottleneck, and thus have more channels (contain more information) than the latents used for reconstruction. It will not be possible to directly decode these features back to audio.

music2latent supports more advanced usage, including GPU memory management controls. Please refer to tutorial.ipynb.

License

This library is released under the CC BY-NC 4.0 license. Please refer to the LICENSE file for more details.

This work was conducted by Marco Pasini during his PhD at Queen Mary University of London, in partnership with Sony Computer Science Laboratories Paris. This work was supervised by Stefan Lattner and George Fazekas.

Release files for music2latent 0.1.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for music2latent 0.1.8
File Size Uploaded
music2latent-0.1.8.tar.gz 19.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for music2latent 0.1.8
File Interpreter ABI Platform
music2latent-0.1.8-py3-none-any.whl Python 3 none any Details

Total release size: 38.9 kB

Release files / music2latent-0.1.8.tar.gz

Download URL music2latent-0.1.8.tar.gz
Size 19.0 kB
Tags Source
SHA-256 checksum
How to use checksums
86ea42f2390a15ed6a8c12278a81a61ff4580207108a7f088b5017ebc5d23687
BLAKE2b-256 checksum
How to use checksums
1529ffd2302eab316e901da3388a0654bfdbb07ffe69551aa80214aab855232f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.18

Release files / music2latent-0.1.8-py3-none-any.whl

Download URL music2latent-0.1.8-py3-none-any.whl
Size 19.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
432a32ca7924148ff09a27df9bf86a59d98ffc495154fcc196177fdb4da37faf
BLAKE2b-256 checksum
How to use checksums
eaab6c743722ec838eef125d904dbad78c3cd6fc5a3eec06a1adedf4a5bb9fcc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.18

Release history Release notifications | RSS feed

This release

0.1.8 This release

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page