Skip to main content

Source Separation Request

Learn how to create your first source separation with the Klangio API.

1. Model Selection

Currently there are two different models to choose for the source separation. One to separate four stems (vocals, piano, drums, rest) and one to separate six stems (vocals, piano, drums, guitar, bass, rest).

One might be tempted to use only the six-stems model, to have a broader range of instruments as output. Depending on your use case, there are simple trade-offs to consider. The four-stem separation model is more accurate in the separation and generally processes the audio faster than the six-stems model. Make sure to check the models that best fit your needs.

2. Request via API

Example python snippet:

  import requests

API_KEY = 'YOUR_KLANGIO_API_KEY'


audio_file = open('{YOUR_FILE_NAME}', 'rb')

query_parameters = {
'model': 'six-stems', # optional, `four-stems` by default
'output': 'wav', # optional, `wav` by default
'webhook_url': '{YOUR_WEBHOOK_ENDPOINT_URL}' # optional, but recommended
}

multipart_params = {
'file': audio_file,
}

resp = requests.post(
'https://api.klang.io/source-separation',
headers={
'kl-api-key': API_KEY
},
params=query_parameters,
files=multipart_params
)

if resp.status_code == 200:
print(resp.json())
# {
# 'job_id': 'SOME_JOB_ID',
# 'creation_date': '2023-01-01',
# 'deletion_date': '2023-02-01',
# 'status_endpoint_url': 'https://api.klang.io/job/{SOME_JOB_ID}/status'
# }