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

# Minimax 兼容音色克隆

export const VoiceCloneErrorHeading = () => {
  useEffect(() => {
    const section = document.createElement("section");
    section.className = "api-section";
    const heading = document.createElement("h4");
    heading.id = "voice-clone-error-codes";
    heading.className = "api-section-heading-title border-b pb-2.5 border-gray-100 dark:border-gray-800";
    heading.textContent = "错误码";
    section.appendChild(heading);
    const table = document.createElement("table");
    table.className = "w-full text-sm mt-4";
    table.innerHTML = `
      <thead><tr><th>HTTP</th><th>code</th><th>含义</th></tr></thead>
      <tbody>
        <tr><td>400</td><td><code>invalid</code></td><td>本地请求解析或参数校验失败</td></tr>
        <tr><td>401</td><td><code>authentication_error</code></td><td>提供的 API 密钥不正确</td></tr>
      </tbody>`;
    section.appendChild(table);
    const placeHeading = () => {
      const responseHeading = Array.from(document.querySelectorAll(".api-section-heading-title")).find(node => (/^(响应|Response)$/).test(node.textContent.trim()));
      const responseSection = responseHeading?.closest(".api-section");
      if (responseSection && responseSection.nextElementSibling !== section) {
        responseSection.after(section);
      } else if (!responseSection) {
        const main = document.querySelector("main");
        if (main && section.parentElement !== main) {
          main.appendChild(section);
        }
      }
    };
    const observer = new MutationObserver(placeHeading);
    observer.observe(document.body, {
      childList: true,
      subtree: true
    });
    placeHeading();
    return () => {
      observer.disconnect();
      section.remove();
    };
  }, []);
  return null;
};

<VoiceCloneErrorHeading />

## 说明

使用 Minimax 兼容格式生成克隆音色。调用前请先通过 [上传文件](/api-reference/endpoint/files/upload) 获取 `file_id`。

* **生成链路**：上传音频获取 `file_id` → 调用本接口生成音色 ID → 在 TTS 接口中使用该音色。
* **音色 ID**：本接口使用 `voice_id` 作为自定义音色 ID，生成后继续在 `voice_setting.voice_id` 中传入。
* **克隆模型**：当前使用 `sensenova-tts-multilingual-2.0`。

## 调用示例

### 1. 上传参考音频

```bash theme={null}
curl -X POST https://api.senseaudio.cn/v1/files/upload \
  -H "Authorization: <API_KEY>" \
  -F "purpose=voice_clone" \
  -F "file=@/path/to/voice.wav"
```

上传成功后，从返回结果中读取 `file.file_id`：

```json theme={null}
{
  "file": {
    "file_id": "file-KQGDEegFNcaWhpNWdoiPZj",
    "filename": "voice.wav",
    "bytes": 228778,
    "purpose": "voice_clone"
  }
}
```

### 2. 生成克隆音色

```bash theme={null}
curl --request POST \
  --url https://api.senseaudio.cn/v1/voice_clone \
  --header 'Authorization: Bearer <API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
    "file_id": "file-KQGDEegFNcaWhpNWdoiPZj",
    "model": "sensenova-tts-multilingual-2.0",
    "text": "你好，这是我的 Minimax 兼容克隆音色试听。",
    "voice_id": "wenrou_yujie_minimax_001"
  }'
```

## 使用克隆音色

生成成功后，将 `voice_id` 传入 [语音合成 HTTP](/api-reference/endpoint/tts/synthesize)：

```json theme={null}
{
  "model": "sensenova-tts-2.0",
  "text": "你好，这是使用 Minimax 兼容克隆音色生成的音频。",
  "voice_setting": {
    "voice_id": "wenrou_yujie_minimax_001"
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.