Lang
Blog

Spleeter- A TensorFlow Based Python Library

ByPayal Mittal
December 12th . 5 min read
Spleeter- A TensorFlow Based Python Library

Extracting out vocals, karaoke, drum, bass, piano or other tracks with clarity, from the original audio source, has been a dream for the music producers, mashup artists, DJs, music signal researchers, etc. They spend a lot of time to isolate tracks from the original source and are even ready to pay a big amount of money for a software/tool to help them do it. Also, every fresher singer wishes to give his/her best performance but struggles due to the unavailability of a good-quality karaoke track.

Deezer has released a really cool piece of software known as Spleeter. This open-source AI audio separation tool has interested the whole MIR (Music Information Retrieval) community and music artists quite a lot because of its exclusively high-quality track separation features. A very interesting fact is that you don’t need to know coding to use it, all you have to do is to type some lines on command-line.

Let’s get a quick detailed view about it-

Overview About Spleeter

Spleeter is a powerful AI (Artificial Intelligence) tool, released by a French Online Music Streaming Service ‘Deezer’, to isolate tracks from the compiled audio sources. It is a Python & TensorFlow based library that uses Machine Learning to separate audio into stems/layers. In a pretty accurate and precise sentence, “Spleeter is a fast and state-of-the-art music source separation tool with pre-trained models.”

spleeter-a-tensorflow-based-python-library_1.jpg

The library comes with three pretrained models, known as:

  • 2 Stems- Vocals and other accompaniments separation
  • 4 Stems- Vocals, drums, bass and other separation
  • 5 Stems- Vocals, drums, bass, piano and other separation

Key Features:

In a report, the Deezer team states the reason behind releasing Spleeter-

We release Spleeter to help the Music Information Retrieval (MIR) community leverage the power of source separation in various MIR tasks, such as vocal lyrics analysis from audio, music transcription, any type of multilabel classification or vocal melody extraction.

Some of its key features are mentioned here-

  • Free & Open Source
  • Faster & Easy to Use
  • High-Quality Audio Separation in No Time

Deezer itself is using Spleeter for some research applications. Herault said in a report that-

We’re using it as a pre-processing tool for complex research tasks such as music categorization, transcription and language detection.

Apart from music source separation, Spleeter has some other potential applications such as Upmixing, active listening, manipulating audio files for security reasons, for educational purposes, etc.

Installation Process -

spleeter-a-tensorflow-based-python-library_2.jpg

There are three ways to install Spleeter i.e. by using Conda, Pip and Docker. For installation using Docker, you can visit the Deezer’s depositary on GitHub. Here, we’ll only check out the first two methods-

How to Install Spleeter Using Pip??

Spleeter can be installed directly by using Pip package manager presuming the following dependencies are installed-

  • ffmpeg
  • libsndfile (will be needed only if you are planning to perform the evaluation.)

To install ffmpeg on Windows:

  • Download Static Build from this link.
  • Extract it in your folder.
  • Open the Command Prompt and Run it as Administrator.
  • Now, run the following command to set the environment variables-
setx /M PATH “path\to\ffmpeg\bin;%PATH%”

Note: Make sure that the characters in your system PATH do not exceed 1024.

  • Now, run the command ffmpeg- version to ensure its working.

To install Spleeter:

  • Firstly, ensure that pip is running on the command line.

You can install the Spleeter library from PyPI (Python Package Index) repository using-

pip install --user spleeter

How to Install Spleeter Using Conda??

Installation of Spleeter using Conda is probably the easiest and convenient way. Here is the procedure-

  • Install Anaconda on your Windows PC from this link.
  • Right-click on your Anaconda folder and click on ‘Git Bash Here’.
  • A command window will open, you need to run the following command-
git clone https://github.com/deezer/spleeter
  • Close the Git Bash and open the Anaconda Prompt.
  • Enter the following commands there-
conda env create -f spleeter/conda/spleeter-cpu.yaml
conda activate spleeter-cpu

And that is it. Now, you are ready to isolate tracks from the audio files.

How to Use??

Spleeter can be used in your own development pipeline as a python library or you can use it directly from the command line. We have already read about all three pretrained models of Spleeter that separate out the audio file in layers. Let’s see how-

2-Stems Model

Basically, a music audio file consists of two components, a vocal track and its instrumental track called karaoke. This model splits out the audio into 2 very basic layers i.e. vocals and karaoke/accompaniment/other.

This is the default step of the isolation process which means if you just have passed the command to separate the audio and haven’t mentioned anything about which model to use, the audio will get separated as per the 2-stems model by-default.

To accomplish the 2-stems separation, you can run any of the following commands on command-line-

spleeter separate -i audio_example.mp3 -o audio_output
spleeter separate -i spleeter/audio_example.mp3 -p spleeter:2stems -o output

Here,

  • audio_example.mp3 is the name of the music track file you are going to split.
  • -i and -o options are indicating towards input and output track respectively.
  • -p option is used for providing model preferences.

The output will be generated in the form of a folder audio_output/audio_example containing two .wav files, namely, accompaniment.wav and vocals.wav.

4-Stems Model

This model splits up the audio file into 4 layers. You can extract out the vocals, drums, bass and other tracks in 4 .wav files, i.e. vocals.wav, drums.wav, bass.wav and other.wav respectively, by running the following command on commandline-

spleeter separate -i audio_example.mp3 -o audio_output -p spleeter:4stems

5-Stems Model

As the name suggests, it rips apart the audio file into 5 stems/layers, i.e. vocals, drums, bass, piano and other. The command for the same is as follows-

spleeter separate -i audio_example.mp3 -o audio_output -p spleeter:5stems

The output will be generated in the form of 5 files: vocals.wav, drums.wav, bass.wav, piano.wav and other.wav.

Final Words -

There are several other audio separation tools and resources available in the market for free but the three pre-trained models of Spleeter are far too easy and able to surpass all of them. These models are like different switches that provide almost all the possible ways to split up an audio file into. What else can you ask for??

We can expect further upgrades in the library in the coming years. Till then, enjoy music mixing and streaming with Spleeter.

Stay tuned with us for similar kinds of blogs about the latest tech releases.

Share:
0
+0