Open-Unmix
Open-Unmix is a PyTorch-based music source separation toolkit that provides pre-trained models and a flexible framework for separating audio into its constituent parts (vocals, drums, bass, other). The current version is 1.3.0, and the library is actively maintained with regular updates addressing bug fixes, performance improvements, and new model releases.
Warnings
- breaking Starting from v1.2.1, the `umxl` model became the new default for inference (both CLI and Python API), potentially changing results compared to previous versions that defaulted to `umxhq`. Additionally, the training argument `--model` was renamed to `--checkpoint`.
- breaking Support for `torchaudio <0.7.0` was dropped in Open-Unmix v1.1.1. Using older versions of `torchaudio` will result in compatibility errors.
- gotcha The `umxl` model, introduced in v1.2.0 and made default in v1.2.1, is only licensed for non-commercial applications. Users must comply with its specific license terms.
- gotcha Python 3.6 support was removed in v1.3.0. The library now requires Python 3.9 or newer.
- gotcha Fixes for broken Zenodo URLs were implemented in v1.3.0. Users of older versions might encounter issues when trying to download pre-trained models, as the URLs could be invalid or change.
Install
-
pip install openunmix
Imports
- separate_audio
from openunmix.separate import separate_audio
Quickstart
import torch
import numpy as np
from openunmix.separate import separate_audio
# Simulate stereo audio data (e.g., 10 seconds at 44.1 kHz)
sr = 44100
duration = 10 # seconds
num_frames = sr * duration
# Create a dummy audio tensor: (channels, samples)
# In a real scenario, load an audio file using torchaudio.load() or similar.
audio_data_np = np.random.randn(2, num_frames).astype(np.float32)
audio_tensor = torch.from_numpy(audio_data_np)
# Separate the audio into stems
# By default, 'umxl' model is used from v1.2.1 onwards
estimates = separate_audio(audio_tensor, rate=sr)
# 'estimates' is a dictionary with keys like 'vocals', 'drums', 'bass', 'other'
# Each value is a torch.Tensor representing the separated stem.
print("Separated stems and their shapes:")
for stem_name, stem_tensor in estimates.items():
print(f" {stem_name}: {stem_tensor.shape}")
# Example: access vocals
vocals = estimates['vocals']
# print(f"Vocals stem shape: {vocals.shape}")