Skip to main content

Voice Upload Endpoint

Overview

The Voice Upload endpoint allows you to upload an audio file and retrieve a voice_id for use with the Text-to Audio endpoint.

Request

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

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

Body Attributes

ParameterDescriptionValues
keyThe API key used to authorize the request.String
nameThe display name assigned to the voice being uploadedString
init_audioThe URL of the audio file to be uploaded. Supported formats are MP3 and WAV. For optimal results, ensure the audio is 10-25 seconds long.URL
base64Specifies whether the audio file is provided as a base64 string.TRUE or FALSE
languageThe language of the voice, which must correspond to the language of the uploaded audio.One of ["english", "arabic", "spanish", "german", "czech", "brazilian portuguese", "chinese", "dutch", "french", "hindi", "hungarian", "italian", "japanese", "korean", "polish", "russian", "turkish"]

Example

Body

Body
{   
"key":"",
"name":"Jacob",
"init_audio":"https://pub-f3505056e06f40d6990886c8e14102b2.r2.dev/audio/jacob.wav",
"language":"english"
}

Request

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

var raw = JSON.stringify({
"key":"",
"name":"Jacob",
"init_audio":"https://pub-f3505056e06f40d6990886c8e14102b2.r2.dev/audio/jacob.wav",
"language":"english"
});

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

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

Response

{
"status": "success",
"message": "voice uploaded successfully",
"voice_id": "jacob"
}