> ## Documentation Index
> Fetch the complete documentation index at: https://docs.musicgpt.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Voice Changer

> Convert the voice from an audio file or URL to a different voice.



## OpenAPI

````yaml POST /v1/VoiceChanger
openapi: 3.1.0
info:
  title: Musicgpt API
  version: 1.0.0
  description: API for retrieving conversion details by ID.
servers:
  - url: https://api.musicgpt.com/api/public
    description: Production server
security: []
paths:
  /v1/VoiceChanger:
    post:
      summary: Convert voice from audio file or URL
      description: Convert the voice from an audio file or URL to a different voice.
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                audio_url:
                  type: string
                  description: URL of audio file to process
                  example: https://example.com/audio.wav
                audio_file:
                  type: string
                  format: binary
                  description: Audio file to upload
                voice_id:
                  type: string
                  description: Voice model ID
                  example: demo-voice-id
                remove_background:
                  type: integer
                  description: 1 to remove background noise, 0 to keep
                  default: 0
                  enum:
                    - 0
                    - 1
                pitch:
                  type: integer
                  description: Pitch adjustment (-12 to +12)
                  default: 0
                  minimum: -12
                  maximum: 12
                webhook_url:
                  type: string
                  description: Callback URL
                  example: https://example.com/callback
              required:
                - voice_id
              anyOf:
                - required:
                    - audio_url
                - required:
                    - audio_file
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  task_id:
                    type: string
                  conversion_id:
                    type: string
                  eta:
                    type: integer
              example:
                success: true
                task_id: 84038e1e-3687-4f7a-9c55-692754b125ee
                conversion_id: e3631817-165d-4f17-a7e2-7008d200ff3e
                eta: 22
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  error:
                    type: string
              example:
                success: false
                error: The file could not be downloaded from the provided URL
        '402':
          description: Payment Required
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  error:
                    type: string
              example:
                success: false
                error: Insufficient credit balance
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  error:
                    type: string
              example:
                success: false
                error: Both audio_url and audio_file cannot be None
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  error:
                    type: string
              example:
                success: false
                error: Internal Server Error
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: Python
          source: >-
            import requests


            url = "https://api.musicgpt.com/api/public/v1/VoiceChanger"


            payload = {
                "audio_url": "<string>",
                "voice_id": "<string>",
                "remove_background": "<int>",
                "pitch": "<int>",
                "webhook_url": "<string>"
            }


            # For file upload instead of URL:

            # files = {'audio_file': open('filepath', 'rb')}


            headers = {
                "Authorization": "<API Key>"
            }


            response = requests.post(url, data=payload, headers=headers)

            # For file upload:

            # response = requests.post(url, data=payload, files=files,
            headers=headers)


            print(response.text)
        - lang: PHP
          source: >-
            <?php

            $url = "https://api.musicgpt.com/api/public/v1/VoiceChanger";

            $apiKey = "<API_KEY>";


            // For URL-based processing

            $data = [
                "audio_url" => "<AUDIO_URL>",
                "voice_id" => "<VOICE_ID>",
                "remove_background" => 0, // 0 or 1
                "pitch" => 0, // -12 to +12
                "webhook_url" => "<WEBHOOK_URL>"
            ];


            // For file upload (uncomment and replace)

            // $data = ["voice_id" => "<VOICE_ID>"];

            // $file = new CURLFile('path/to/audio.wav', 'audio/wav',
            'audio_file');


            $headers = [
                "Authorization: " . $apiKey
            ];


            $ch = curl_init();

            curl_setopt($ch, CURLOPT_URL, $url);

            curl_setopt($ch, CURLOPT_POST, 1);

            curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

            // For file upload:

            // curl_setopt($ch, CURLOPT_POSTFIELDS, array_merge($data,
            ['audio_file' => $file]));

            curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);


            $response = curl_exec($ch);

            curl_close($ch);


            echo $response;

            ?>
        - lang: Go
          source: "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"mime/multipart\"\n\t\"net/http\"\n\t\"os\"\n)\n\nfunc main() {\n\turl := \"https://api.musicgpt.com/api/public/v1/VoiceChanger\"\n\tapiKey := \"<API_KEY>\"\n\n\t// For URL-based processing\n\tpayload := map[string]string{\n\t\t\"audio_url\":        \"<AUDIO_URL>\",\n\t\t\"voice_id\":        \"<VOICE_ID>\",\n\t\t\"remove_background\": \"0\",\n\t\t\"pitch\":           \"0\",\n\t\t\"webhook_url\":     \"<WEBHOOK_URL>\",\n\t}\n\n\t// For file upload (uncomment and replace)\n\t// file, _ := os.Open(\"audio.wav\")\n\t// defer file.Close()\n\n\tbody := &bytes.Buffer{}\n\twriter := multipart.NewWriter(body)\n\n\tfor key, val := range payload {\n\t\t_ = writer.WriteField(key, val)\n\t}\n\n\t// For file upload:\n\t// part, _ := writer.CreateFormFile(\"audio_file\", \"audio.wav\")\n\t// io.Copy(part, file)\n\twriter.Close()\n\n\treq, _ := http.NewRequest(\"POST\", url, body)\n\treq.Header.Set(\"Authorization\", apiKey)\n\treq.Header.Set(\"Content-Type\", writer.FormDataContentType())\n\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\tdefer resp.Body.Close()\n\n\tresponse, _ := io.ReadAll(resp.Body)\n\tfmt.Println(string(response))\n}"
        - lang: Java
          source: |-
            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>";

                    // For URL-based processing
                    RequestBody requestBody = new FormBody.Builder()
                            .add("audio_url", "<AUDIO_URL>")
                            .add("voice_id", "<VOICE_ID>")
                            .add("remove_background", "0")
                            .add("pitch", "0")
                            .add("webhook_url", "<WEBHOOK_URL>")
                            .build();

                    // For file upload (uncomment and replace)
                    /*
                    File audioFile = new File("audio.wav");
                    RequestBody requestBody = new MultipartBody.Builder()
                            .setType(MultipartBody.FORM)
                            .addFormDataPart("voice_id", "<VOICE_ID>")
                            .addFormDataPart("audio_file", "audio.wav",
                                    RequestBody.create(audioFile, MediaType.parse("audio/wav")))
                            .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());
                    }
                }
            }
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization

````