Try to using Open-Unmix(UMX) to separate sound source for each instrument part from music file (PyTorch)
Tried it
i tried to use this Open-Unmix (ver. PyTorch) posted on github.
Paper: Open-Unmix – A Reference Implementation for Music Source Separation
Input music file (.wav)
- input_file.wav
Output separated file (.wav)
- input_file_bass.wav Bass
- input_file_drums.wav Drums
- input_file_other.wav Other parts (Guitars, Keyboards, etc)
- input_file_vocals.wav Vocals
Done!
As expected, it was not possible to separate each part as clear as before the mix, but to some extent it was possible.
…Since there is no music file that can be posted for the result, so i wrote only how to do it for now.
How to use (Usage)
Execution environment
- Linux Ubuntu 18.04 LTS (Windows10 (1903) + WSL)
Prepare for python environment
i used python3.7.
Activate python virtual environment.
$ virtualenv -p python3.7 venv37 $ source venv37/bin/activate (venv37)$
Install required libraries
“Anaconda” is recommended in “Getting started” of README.md, but i tried using with just ‘pip’.
$ pip install musdb==0.3.1 $ pip install norbert==0.2.0 $ pip install museval==0.3.0 $ pip install numpy==1.16 $ pip install scipy==1.3 $ pip install scikit-learn==0.21 $ pip install tqdm==4.32 $ pip install ffmpeg $ pip install resampy
Install PyTorch with reference to the following.
https://pytorch.org/get-started/previous-versions/#linux-and-windows-1
$ pip install torch==1.2.0 torchvision==0.4.0 -f https://download.pytorch.org/whl/torch_stable.html
Check what was installed (excerpt)
$ pip freeze ffmpeg==1.4 musdb==0.3.1 museval==0.3.0 norbert==0.2.0 numpy==1.16.0 resampy==0.2.2 scikit-learn==0.21.0 scipy==1.3.0 torch==1.2.0+cu92 torchvision==0.4.0+cu92 tqdm==4.32.0
Prepare for Open-Unmix
Clone ‘open-unmix-pytorch’ from github repository.
$ git clone https://github.com/sigsep/open-unmix-pytorch.git $ cd open-unmix-pytorch/
Prepere for music data file
Prepare a music file to be separated with wav or flac.
open-unmix-pytorch/ input_file.wav
Run
Run the following command on the open-unmix-pytorch directory.
$ python test.py input_file.wav --model umxhq
When i tried to separate with a song about 1:30 in length (about 16MByte), it was completed in about tens of seconds without any error.
$ python test.py input_file.wav --model umxhq 100%|█████████████████████████████████████████████████████████████████████████████████████| 4/4 [00:14<00:00, 3.64s/it] $
Separated into four files: vocals, bass, drums, and other parts (guitars, keyboards, etc.).
open-unmix-pytorch/ input_file_umxhq/ input_file_bass.wav input_file_drums.wav input_file_other.wav input_file_vocals.wav
The part to be separated can be specified with the option [–target].
$ python test.py input_file.wav --model umxhq --target=vocals
For example, if vocals is specified, it can be separated into vocals part and others as shown below.
open-unmix-pytorch/ input_file_umxhq/ input_file_accompaniment.wav Bass, Drums, Guitars, Keyboards input_file_vocals.wav Vocals
That’s it!