Skip to main content

Music Gen Endpoint

Overview

Music gen helps to generate audio based on input parameters

Request

--request POST 'https://modelslab.com/api/v6/voice/music_gen' \

Make a POST request to https://modelslab.com/api/v6/voice/music_gen endpoint and pass the required parameters as a request body.

Body Attributes

ParameterDescription
keyYour API Key used for request authorization
promptThe input text for audio generation.
init_audioThe conditioning melody for audio generation
sampling_rateThe sampling rate of the generated audio.Upper Bound: No strict upper bound. Lower Bound: 10000 Default: 32000
max_new_tokenThe maximum number of new tokens for audio generation. Upper Bound: 1024 and Lower Bound: Minimum of 256.
base64Whether the input sound clip is in base64 or not. Should be true or false. Defaults to false.
tempWhether you want temporary links or not. This is useful if your country blocks access to our storage sites. Should be true or false. Defaults
webhookSet an URL to get a POST API call once the image generation is complete.
track_idThis ID is returned in the response to the webhook API call. This will be used to identify the webhook request.

Example

Body

Body
{
"key":"",
"prompt":"rock music from the 90s",
"init_audio":"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/generations/9850abf6-df8a-4d3e-9d78-501bbd64adeb.wav",
"sampling_rate":5000,
"base64":false,
"temp": false,
"webhook":"",
"track_id":""
}

Request

var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
"key":"",
"prompt":"rock music from the 90s",
"init_audio":"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/generations/9850abf6-df8a-4d3e-9d78-501bbd64adeb.wav",
"sampling_rate":5000,
"base64":false,
"temp": false,
"webhook":"",
"track_id":""
});

var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};

fetch("https://modelslab.com/api/v6/voice/music_gen", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));

Response

{
"status": "success",
"generationTime": 10.58609676361084,
"id": 43730,
"output": [
"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/generations/770b2376-93a7-49eb-8275-afecbba16a6e.wav"
],
"proxy_links": [
"https://cdn2.stablediffusionapi.com/generations/770b2376-93a7-49eb-8275-afecbba16a6e.wav"
],
"meta": {
"base64": "no",
"conditioning_melody": [
"tmp/0-770b2376-93a7-49eb-8275-afecbba16a6e.wav"
],
"filename": "770b2376-93a7-49eb-8275-afecbba16a6e.wav",
"input_text": "rock music from the 90s",
"max_new_token": 256,
"sampling_rate": 5000,
"temp": "no"
}
}