Voice Upload Endpoint
Overview
The audio voice endpoint allows you to upload audio and use the voice_id returned with 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
Parameter | Description | Values |
---|---|---|
key | Your API Key used for request authorization | string |
name | Display name of the voice you want to upload | string |
init_audio | Audio URL of the voice file to upload. Only MP3 and WAV formats are allowed. Should be 10-25 seconds long for best results. | URL |
base64 | to upload base64 string, true or false | boolean |
language | Language of the voice. Ensure it matches the language of the uploaded voice. | 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
- JS
- PHP
- NODE
- PYTHON
- JAVA
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));
<?php
$payload = [
"key" => "",
"name" => "Jacob",
"init_audio" => "https://pub-f3505056e06f40d6990886c8e14102b2.r2.dev/audio/jacob.wav",
"language" => "english"
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://modelslab.com/api/v6/voice/voice_upload',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://modelslab.com/api/v6/voice/voice_upload',
'headers': {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"key":"",
"name":"Jacob",
"init_audio":"https://pub-f3505056e06f40d6990886c8e14102b2.r2.dev/audio/jacob.wav",
"language":"english"
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "https://modelslab.com/api/v6/voice/voice_upload"
payload = json.dumps({
"key":"",
"name":"Jacob",
"init_audio":"https://pub-f3505056e06f40d6990886c8e14102b2.r2.dev/audio/jacob.wav",
"language":"english"
})
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"key\":\"\",\n \"init_audio\":\"https://pub-f3505056e06f40d6990886c8e14102b2.r2.dev/audio/jacob.wav\",\n \"language\":\"english\",\n \"name\":\"Jacobs\"\n}");
Request request = new Request.Builder()
.url("https://modelslab.com/api/v6/voice/voice_upload")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Response
{
"status": "success",
"message": "voice uploaded successfully",
"voice_id": "jacob"
}