Python
import requests
url = "https://api.musicgpt.com/api/public/v1/VoiceChanger"
headers = {
"Authorization": "<API_KEY>"
}
data = {
"voice_id": "e0bb585f-b798-4bac-ac4e-de7fff38f9d75",
"remove_background": 1,
"pitch": 0,
"webhook_url": "https://example.com/my-webhook"
}
# Option 1: audio_url
data["audio_url"] = "<YOUR_AUDIO_URL>"
response = requests.post(url, headers=headers, data=data)
# Option 2: File Upload
# with open("song.mp3", "rb") as f:
# files = {"audio_file": f}
# response = requests.post(url, headers=headers, data=data, files=files)
print(response.json())<?php
$url = "https://api.musicgpt.com/api/public/v1/VoiceChanger";
$apiKey = "<API_KEY>";
$data = [
"voice_id" => "voice_12345",
"remove_background" => 1,
"pitch" => 0,
"webhook_url" => "https://example.com/my-webhook"
];
// Option 1: audio_url
$data["audio_url"] = "<YOUR_AUDIO_URL>";
// Option 2: File Upload
// $data["audio_file"] = new CURLFile("song.mp3");
$headers = [
"Authorization: " . $apiKey
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>package main
import (
"bytes"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
)
func main() {
url := "https://api.musicgpt.com/api/public/v1/VoiceChanger"
apiKey := "<API_KEY>"
payload := map[string]string{
"voice_id": "voice_12345",
"remove_background": "1",
"pitch": "0",
"webhook_url": "https://example.com/my-webhook",
}
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
for key, val := range payload {
_ = writer.WriteField(key, val)
}
// Option 1: audio_url
writer.WriteField("audio_url", "<YOUR_AUDIO_URL>")
// Option 2: File Upload
// file, _ := os.Open("song.mp3")
// defer file.Close()
// part, _ := writer.CreateFormFile("audio_file", "song.mp3")
// io.Copy(part, file)
writer.Close()
req, _ := http.NewRequest("POST", url, body)
req.Header.Set("Authorization", apiKey)
req.Header.Set("Content-Type", writer.FormDataContentType())
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer resp.Body.Close()
response, _ := io.ReadAll(resp.Body)
fmt.Println(string(response))
}import okhttp3.*;
import java.io.File;
import java.io.IOException;
public class VoiceChanger {
public static void main(String[] args) throws IOException {
String url = "https://api.musicgpt.com/api/public/v1/VoiceChanger";
String apiKey = "<API_KEY>";
// Option 1: audio_url
RequestBody requestBody = new FormBody.Builder()
.add("audio_url", "<YOUR_AUDIO_URL>")
.add("voice_id", "voice_12345")
.add("remove_background", "1")
.add("pitch", "0")
.add("webhook_url", "https://example.com/my-webhook")
.build();
// Option 2: File Upload
// File audioFile = new File("song.mp3");
// RequestBody requestBody = new MultipartBody.Builder()
// .setType(MultipartBody.FORM)
// .addFormDataPart("voice_id", "voice_12345")
// .addFormDataPart("remove_background", "1")
// .addFormDataPart("pitch", "0")
// .addFormDataPart("webhook_url", "https://example.com/my-webhook")
// .addFormDataPart("audio_file", audioFile.getName(),
// RequestBody.create(audioFile, MediaType.parse("audio/mpeg")))
// .build();
Request request = new Request.Builder()
.url(url)
.post(requestBody)
.header("Authorization", apiKey)
.build();
OkHttpClient client = new OkHttpClient();
try (Response response = client.newCall(request).execute()) {
System.out.println(response.body().string());
}
}
}curl --request POST \
--url https://api.musicgpt.com/api/public/v1/VoiceChanger \
--header 'Authorization: <api-key>' \
--header 'Content-Type: multipart/form-data' \
--form audio_url=https://example.com/audio.wav \
--form voice_id=demo-voice-id \
--form 'audio_file=<string>' \
--form remove_background=0 \
--form pitch=0 \
--form webhook_url=https://example.com/callback \
--form 0.audio_file='@example-file' \
--form 1.audio_file='@example-file'const form = new FormData();
form.append('audio_url', 'https://example.com/audio.wav');
form.append('voice_id', 'demo-voice-id');
form.append('audio_file', '<string>');
form.append('remove_background', '0');
form.append('pitch', '0');
form.append('webhook_url', 'https://example.com/callback');
form.append('0.audio_file', '{
"fileName": "example-file"
}');
form.append('1.audio_file', '{
"fileName": "example-file"
}');
const options = {method: 'POST', headers: {Authorization: '<api-key>'}};
options.body = form;
fetch('https://api.musicgpt.com/api/public/v1/VoiceChanger', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));require 'uri'
require 'net/http'
url = URI("https://api.musicgpt.com/api/public/v1/VoiceChanger")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"audio_url\"\r\n\r\nhttps://example.com/audio.wav\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"voice_id\"\r\n\r\ndemo-voice-id\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"audio_file\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"remove_background\"\r\n\r\n0\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"pitch\"\r\n\r\n0\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"webhook_url\"\r\n\r\nhttps://example.com/callback\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"0.audio_file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"1.audio_file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"success": true,
"task_id": "84038e1e-3687-4f7a-9c55-692754b125ee",
"conversion_id": "e3631817-165d-4f17-a7e2-7008d200ff3e",
"eta": 22
}{
"success": false,
"error": "The file could not be downloaded from the provided URL"
}{
"success": false,
"error": "Insufficient credit balance"
}{
"success": false,
"error": "Both audio_url and audio_file cannot be None"
}{
"success": false,
"error": "Internal Server Error"
}Conversion Endpoints
Voice Changer
Convert the voice from an audio file or URL to a different voice.
POST
/
v1
/
VoiceChanger
Python
import requests
url = "https://api.musicgpt.com/api/public/v1/VoiceChanger"
headers = {
"Authorization": "<API_KEY>"
}
data = {
"voice_id": "e0bb585f-b798-4bac-ac4e-de7fff38f9d75",
"remove_background": 1,
"pitch": 0,
"webhook_url": "https://example.com/my-webhook"
}
# Option 1: audio_url
data["audio_url"] = "<YOUR_AUDIO_URL>"
response = requests.post(url, headers=headers, data=data)
# Option 2: File Upload
# with open("song.mp3", "rb") as f:
# files = {"audio_file": f}
# response = requests.post(url, headers=headers, data=data, files=files)
print(response.json())<?php
$url = "https://api.musicgpt.com/api/public/v1/VoiceChanger";
$apiKey = "<API_KEY>";
$data = [
"voice_id" => "voice_12345",
"remove_background" => 1,
"pitch" => 0,
"webhook_url" => "https://example.com/my-webhook"
];
// Option 1: audio_url
$data["audio_url"] = "<YOUR_AUDIO_URL>";
// Option 2: File Upload
// $data["audio_file"] = new CURLFile("song.mp3");
$headers = [
"Authorization: " . $apiKey
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>package main
import (
"bytes"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
)
func main() {
url := "https://api.musicgpt.com/api/public/v1/VoiceChanger"
apiKey := "<API_KEY>"
payload := map[string]string{
"voice_id": "voice_12345",
"remove_background": "1",
"pitch": "0",
"webhook_url": "https://example.com/my-webhook",
}
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
for key, val := range payload {
_ = writer.WriteField(key, val)
}
// Option 1: audio_url
writer.WriteField("audio_url", "<YOUR_AUDIO_URL>")
// Option 2: File Upload
// file, _ := os.Open("song.mp3")
// defer file.Close()
// part, _ := writer.CreateFormFile("audio_file", "song.mp3")
// io.Copy(part, file)
writer.Close()
req, _ := http.NewRequest("POST", url, body)
req.Header.Set("Authorization", apiKey)
req.Header.Set("Content-Type", writer.FormDataContentType())
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer resp.Body.Close()
response, _ := io.ReadAll(resp.Body)
fmt.Println(string(response))
}import okhttp3.*;
import java.io.File;
import java.io.IOException;
public class VoiceChanger {
public static void main(String[] args) throws IOException {
String url = "https://api.musicgpt.com/api/public/v1/VoiceChanger";
String apiKey = "<API_KEY>";
// Option 1: audio_url
RequestBody requestBody = new FormBody.Builder()
.add("audio_url", "<YOUR_AUDIO_URL>")
.add("voice_id", "voice_12345")
.add("remove_background", "1")
.add("pitch", "0")
.add("webhook_url", "https://example.com/my-webhook")
.build();
// Option 2: File Upload
// File audioFile = new File("song.mp3");
// RequestBody requestBody = new MultipartBody.Builder()
// .setType(MultipartBody.FORM)
// .addFormDataPart("voice_id", "voice_12345")
// .addFormDataPart("remove_background", "1")
// .addFormDataPart("pitch", "0")
// .addFormDataPart("webhook_url", "https://example.com/my-webhook")
// .addFormDataPart("audio_file", audioFile.getName(),
// RequestBody.create(audioFile, MediaType.parse("audio/mpeg")))
// .build();
Request request = new Request.Builder()
.url(url)
.post(requestBody)
.header("Authorization", apiKey)
.build();
OkHttpClient client = new OkHttpClient();
try (Response response = client.newCall(request).execute()) {
System.out.println(response.body().string());
}
}
}curl --request POST \
--url https://api.musicgpt.com/api/public/v1/VoiceChanger \
--header 'Authorization: <api-key>' \
--header 'Content-Type: multipart/form-data' \
--form audio_url=https://example.com/audio.wav \
--form voice_id=demo-voice-id \
--form 'audio_file=<string>' \
--form remove_background=0 \
--form pitch=0 \
--form webhook_url=https://example.com/callback \
--form 0.audio_file='@example-file' \
--form 1.audio_file='@example-file'const form = new FormData();
form.append('audio_url', 'https://example.com/audio.wav');
form.append('voice_id', 'demo-voice-id');
form.append('audio_file', '<string>');
form.append('remove_background', '0');
form.append('pitch', '0');
form.append('webhook_url', 'https://example.com/callback');
form.append('0.audio_file', '{
"fileName": "example-file"
}');
form.append('1.audio_file', '{
"fileName": "example-file"
}');
const options = {method: 'POST', headers: {Authorization: '<api-key>'}};
options.body = form;
fetch('https://api.musicgpt.com/api/public/v1/VoiceChanger', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));require 'uri'
require 'net/http'
url = URI("https://api.musicgpt.com/api/public/v1/VoiceChanger")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"audio_url\"\r\n\r\nhttps://example.com/audio.wav\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"voice_id\"\r\n\r\ndemo-voice-id\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"audio_file\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"remove_background\"\r\n\r\n0\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"pitch\"\r\n\r\n0\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"webhook_url\"\r\n\r\nhttps://example.com/callback\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"0.audio_file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"1.audio_file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"success": true,
"task_id": "84038e1e-3687-4f7a-9c55-692754b125ee",
"conversion_id": "e3631817-165d-4f17-a7e2-7008d200ff3e",
"eta": 22
}{
"success": false,
"error": "The file could not be downloaded from the provided URL"
}{
"success": false,
"error": "Insufficient credit balance"
}{
"success": false,
"error": "Both audio_url and audio_file cannot be None"
}{
"success": false,
"error": "Internal Server Error"
}Authorizations
Body
multipart/form-data
- Option 1
- Option 2
Input audio URL (supported format: YouTube URL).
Example:
"https://example.com/audio.wav"
Voice model ID
Example:
"demo-voice-id"
Audio file to upload
1 to remove background noise, 0 to keep
Available options:
0, 1 Pitch adjustment (-12 to +12)
Required range:
-12 <= x <= 12Callback URL
Example:
"https://example.com/callback"
⌘I