Skip to main content

Enterprise: Music Gen Endpoint

Overview

Music gen helps to generate audio based on input parameters

Request

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

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

caution

Make sure you add your s3 details for voice_cloning server, so you can receive image generated in your bucket. Images generated without s3 details being added will be delete after 24 hours

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/2e4c9960-7425-4720-82a1-a373063bf635.wav",
"sampling_rate":10000,
"base64":false,
"temp": false,
"webhook":null,
"track_id":null
}

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/2e4c9960-7425-4720-82a1-a373063bf635.wav",
"sampling_rate":10000,
"base64":false,
"temp": false,
"webhook":null,
"track_id":null
});

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

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

Response

{
"status": "success",
"generationTime": 4.8882811069488525,
"id": 310815,
"output": [
"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/generations/30ea5aee-fba8-4b65-bf71-2fc2b6b197c0.wav"
],
"proxy_links": [
"https://cdn2.stablediffusionapi.com/generations/30ea5aee-fba8-4b65-bf71-2fc2b6b197c0.wav"
],
"meta": {
"base64": "no",
"conditioning_melody": null,
"filename": "30ea5aee-fba8-4b65-bf71-2fc2b6b197c0.wav",
"input_text": "rock music from the 90s",
"max_new_token": 256,
"sampling_rate": 10000,
"temp": "no"
}
}