> This is a page from the ElevenLabs documentation. For a complete page index, fetch https://elevenlabs.io/docs/llms.txt. For the full documentation in a single file, fetch https://elevenlabs.io/docs/llms-full.txt.

# 编辑音色设置

POST https://api.elevenlabs.io/v1/voices/{voice_id}/settings/edit
Content-Type: application/json

编辑特定音色的设置。"similarity_boost" 对应 Web 应用中的 "Clarity + Similarity Enhancement"，"stability" 对应 Web 应用中的 "Stability" 滑块。

Reference: https://elevenlabs.io/docs/api-reference/voices/settings/update

## Servers

- `https://api.elevenlabs.io` (Production, default)
- `https://api.us.elevenlabs.io` (Production US)
- `https://api.eu.residency.elevenlabs.io` (Production EU)
- `https://api.in.residency.elevenlabs.io` (Production India)
- `https://api.sg.residency.elevenlabs.io` (Production Singapore)

## Request

### Path parameters

- `voice_id` (string, required) — 要使用的音色 ID。可使用 [获取音色](/docs/api-reference/voices/search) 端点列出所有可用音色。

### Body (application/json)

This endpoint expects a VoiceSettingsResponseModel.

- `stability` (double, optional, nullable, default: 0.5) — 决定音色的稳定性以及每次生成之间的随机性。较低的值会带来更丰富的情感范围。较高的值可能使音色较为单调，情感有限。
- `use_speaker_boost` (boolean, optional, nullable, default: true) — 此设置可提高与原始说话者的相似度。使用后计算负载会略微增加，从而提高延迟。
- `similarity_boost` (double, optional, nullable, default: 0.75) — 决定 AI 在尝试复现原始音色时应遵循原始音色的程度。
- `style` (double, optional, nullable, default: 0) — 决定音色的风格夸张程度。此设置会尝试增强原始说话者的风格。设为非 0 值时会消耗额外计算资源，并可能增加延迟。
- `speed` (double, optional, nullable, default: 1) — 调整语速。值为 1.0 时使用默认语速；小于 1.0 会减慢语音，大于 1.0 会加快语音。
- `clone_strength` (double, optional, nullable) — 控制音色与专业语音克隆样本的匹配程度，范围为 0（低）到 1（高）。大多数情况下建议设为 0。仅当默认设置出现问题时才提高此值。仅适用于为所选 v4 模型微调的专业语音克隆。

## Response

### 200

成功响应

- `status` (string, required) — 编辑音色设置请求的状态。如果请求成功，状态将为 'ok'。否则将返回状态为 500 的错误消息。

## Errors

### 422 Unprocessable Entity Error

验证错误。

- `detail` (list of ValidationError, optional)

## Types

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)

### ValidationErrorLocItems

- string
- integer

## Examples

**Request**

```json
{
  "stability": 1,
  "use_speaker_boost": true,
  "similarity_boost": 1,
  "style": 0,
  "speed": 1
}
```

**Response**

```json
{
  "status": "ok"
}
```

**SDK Code**

```python
import requests

url = "https://api.elevenlabs.io/v1/voices/21m00Tcm4TlvDq8ikWAM/settings/edit"

payload = {
    "stability": 1,
    "use_speaker_boost": True,
    "similarity_boost": 1,
    "style": 0,
    "speed": 1
}
headers = {"Content-Type": "application/json"}

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

print(response.json())
```

```javascript
const url = 'https://api.elevenlabs.io/v1/voices/21m00Tcm4TlvDq8ikWAM/settings/edit';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"stability":1,"use_speaker_boost":true,"similarity_boost":1,"style":0,"speed":1}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.elevenlabs.io/v1/voices/21m00Tcm4TlvDq8ikWAM/settings/edit"

	payload := strings.NewReader("{\n  \"stability\": 1,\n  \"use_speaker_boost\": true,\n  \"similarity_boost\": 1,\n  \"style\": 0,\n  \"speed\": 1\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.elevenlabs.io/v1/voices/21m00Tcm4TlvDq8ikWAM/settings/edit")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"stability\": 1,\n  \"use_speaker_boost\": true,\n  \"similarity_boost\": 1,\n  \"style\": 0,\n  \"speed\": 1\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.elevenlabs.io/v1/voices/21m00Tcm4TlvDq8ikWAM/settings/edit")
  .header("Content-Type", "application/json")
  .body("{\n  \"stability\": 1,\n  \"use_speaker_boost\": true,\n  \"similarity_boost\": 1,\n  \"style\": 0,\n  \"speed\": 1\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.elevenlabs.io/v1/voices/21m00Tcm4TlvDq8ikWAM/settings/edit', [
  'body' => '{
  "stability": 1,
  "use_speaker_boost": true,
  "similarity_boost": 1,
  "style": 0,
  "speed": 1
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.elevenlabs.io/v1/voices/21m00Tcm4TlvDq8ikWAM/settings/edit");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"stability\": 1,\n  \"use_speaker_boost\": true,\n  \"similarity_boost\": 1,\n  \"style\": 0,\n  \"speed\": 1\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "stability": 1,
  "use_speaker_boost": true,
  "similarity_boost": 1,
  "style": 0,
  "speed": 1
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.elevenlabs.io/v1/voices/21m00Tcm4TlvDq8ikWAM/settings/edit")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```