设计音色
curl --request POST \
--url https://api.vivix.ai/v1/voices/design \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"instruction": "A mature male news anchor with a deep, steady voice",
"sample_text": "Welcome to tonight's broadcast.",
"language": "zh",
"name": "Studio Anchor"
}
EOFimport requests
url = "https://api.vivix.ai/v1/voices/design"
payload = {
"instruction": "A mature male news anchor with a deep, steady voice",
"sample_text": "Welcome to tonight's broadcast.",
"language": "zh",
"name": "Studio Anchor"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
instruction: 'A mature male news anchor with a deep, steady voice',
sample_text: 'Welcome to tonight\'s broadcast.',
language: 'zh',
name: 'Studio Anchor'
})
};
fetch('https://api.vivix.ai/v1/voices/design', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.vivix.ai/v1/voices/design",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'instruction' => 'A mature male news anchor with a deep, steady voice',
'sample_text' => 'Welcome to tonight\'s broadcast.',
'language' => 'zh',
'name' => 'Studio Anchor'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.vivix.ai/v1/voices/design"
payload := strings.NewReader("{\n \"instruction\": \"A mature male news anchor with a deep, steady voice\",\n \"sample_text\": \"Welcome to tonight's broadcast.\",\n \"language\": \"zh\",\n \"name\": \"Studio Anchor\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.vivix.ai/v1/voices/design")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"instruction\": \"A mature male news anchor with a deep, steady voice\",\n \"sample_text\": \"Welcome to tonight's broadcast.\",\n \"language\": \"zh\",\n \"name\": \"Studio Anchor\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.vivix.ai/v1/voices/design")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"instruction\": \"A mature male news anchor with a deep, steady voice\",\n \"sample_text\": \"Welcome to tonight's broadcast.\",\n \"language\": \"zh\",\n \"name\": \"Studio Anchor\"\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "success",
"data": {
"voice_id": "voice_8f2c1a4e-5d67-4b03-a9f1-2e6c7b0d5a94",
"name": "Studio Anchor",
"language": "zh",
"preview_audio_url": "https://static.vivi-x.ai/voice_preview/2026/10/13/8f2c1a4e5d674b03/a9f12e6c7b0d5a94.wav"
}
}音色
设计音色
根据文本描述创建音色,无需参考音频。启动会话时,将返回的 voice_id 传给 pipeline_config.tts_config.tts_voice_id。
POST
/
v1
/
voices
/
design
设计音色
curl --request POST \
--url https://api.vivix.ai/v1/voices/design \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"instruction": "A mature male news anchor with a deep, steady voice",
"sample_text": "Welcome to tonight's broadcast.",
"language": "zh",
"name": "Studio Anchor"
}
EOFimport requests
url = "https://api.vivix.ai/v1/voices/design"
payload = {
"instruction": "A mature male news anchor with a deep, steady voice",
"sample_text": "Welcome to tonight's broadcast.",
"language": "zh",
"name": "Studio Anchor"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
instruction: 'A mature male news anchor with a deep, steady voice',
sample_text: 'Welcome to tonight\'s broadcast.',
language: 'zh',
name: 'Studio Anchor'
})
};
fetch('https://api.vivix.ai/v1/voices/design', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.vivix.ai/v1/voices/design",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'instruction' => 'A mature male news anchor with a deep, steady voice',
'sample_text' => 'Welcome to tonight\'s broadcast.',
'language' => 'zh',
'name' => 'Studio Anchor'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.vivix.ai/v1/voices/design"
payload := strings.NewReader("{\n \"instruction\": \"A mature male news anchor with a deep, steady voice\",\n \"sample_text\": \"Welcome to tonight's broadcast.\",\n \"language\": \"zh\",\n \"name\": \"Studio Anchor\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.vivix.ai/v1/voices/design")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"instruction\": \"A mature male news anchor with a deep, steady voice\",\n \"sample_text\": \"Welcome to tonight's broadcast.\",\n \"language\": \"zh\",\n \"name\": \"Studio Anchor\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.vivix.ai/v1/voices/design")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"instruction\": \"A mature male news anchor with a deep, steady voice\",\n \"sample_text\": \"Welcome to tonight's broadcast.\",\n \"language\": \"zh\",\n \"name\": \"Studio Anchor\"\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "success",
"data": {
"voice_id": "voice_8f2c1a4e-5d67-4b03-a9f1-2e6c7b0d5a94",
"name": "Studio Anchor",
"language": "zh",
"preview_audio_url": "https://static.vivi-x.ai/voice_preview/2026/10/13/8f2c1a4e5d674b03/a9f12e6c7b0d5a94.wav"
}
}创建会话时使用音色
创建会话时使用音色
{
"pipeline_config": {
"tts_config": {
"tts_voice_id": "voice_8f2c1a4e"
}
}
}
tts_voice_id:服务会为该音色填充 tts_provider 和 tts_model_id。这与克隆音色有什么区别?
这与克隆音色有什么区别?
两个端点以相同结构返回可用音色,区别在于音色的来源:
两者共用一个音色配额,因此设计音色与克隆音色一样,会计入
| 克隆音色 | 设计音色 | |
|---|---|---|
| 输入 | 参考音频(file_id) | 文本描述(instruction) |
| 是否需要先录制音频 | 是 | 否 |
| 额外响应字段 | — | preview_audio_url |
是否计入 max_voices | 是 | 是,共用同一配额 |
max_voices 上限。编写 instruction
编写 instruction
instruction 描述音色,而不是要说的内容。应具体描述表达方式:A warm female narrator in her thirties, slightly husky, unhurried pace, gentle emphasis on the ends of sentences.
预览音频
预览音频
preview_audio_url 是长期有效、无需鉴权的 WAV(单声道、16 kHz),可以直接在 <audio> 元素中播放或下载。无法生成预览时,该字段会缺失。缺少预览并不表示音色创建失败——音色仍可用于会话。无需轮询状态字段:接口返回响应即表示音色已经可用。错误
错误
错误响应使用相同的
{code, message, data} 封装;非零 code 表示具体错误。| 情况 | 错误码 |
|---|---|
缺少 instruction 或 name | 20003 missing required parameter |
language 不是 zh 或 en,且缺少 sample_text | 20003 missing required parameter |
instruction 或 sample_text 超过 1500 个字符 | 20004 invalid parameter |
name 超过 100 个字符 | 20004 invalid parameter |
language 无效 | 20004 invalid parameter |
达到音色配额 max_voices(HTTP 403) | 30010 voice clone quota exceeded |
| 设计服务商调用失败(HTTP 502) | 30007 voice clone provider failed |
| API 密钥缺失或无效 | 10001 missing api key 或 10003 invalid api key |
请求体
application/json