克隆音色
curl --request POST \
--url https://api.vivix.ai/v1/voices \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Studio Host",
"file_id": "file_aud_a1b2c3d4e5f6",
"language": "zh"
}
'import requests
url = "https://api.vivix.ai/v1/voices"
payload = {
"name": "Studio Host",
"file_id": "file_aud_a1b2c3d4e5f6",
"language": "zh"
}
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({name: 'Studio Host', file_id: 'file_aud_a1b2c3d4e5f6', language: 'zh'})
};
fetch('https://api.vivix.ai/v1/voices', 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",
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([
'name' => 'Studio Host',
'file_id' => 'file_aud_a1b2c3d4e5f6',
'language' => 'zh'
]),
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"
payload := strings.NewReader("{\n \"name\": \"Studio Host\",\n \"file_id\": \"file_aud_a1b2c3d4e5f6\",\n \"language\": \"zh\"\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")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Studio Host\",\n \"file_id\": \"file_aud_a1b2c3d4e5f6\",\n \"language\": \"zh\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.vivix.ai/v1/voices")
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 \"name\": \"Studio Host\",\n \"file_id\": \"file_aud_a1b2c3d4e5f6\",\n \"language\": \"zh\"\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "success",
"data": {
"voice_id": "voice_9f1c2a7b",
"name": "Studio Host",
"language": "zh"
}
}音色
克隆音色
使用已上传音频的 file_id 克隆音色并返回 voice_id。启动会话时,将该 ID 传给 pipeline_config.tts_config.tts_voice_id。
参考音频必须是最长 15 秒的连续清晰语音,并且能够被转录。请先通过上传音频接口上传。克隆的音色会计入工作区的 max_voices 配额。
POST
/
v1
/
voices
克隆音色
curl --request POST \
--url https://api.vivix.ai/v1/voices \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Studio Host",
"file_id": "file_aud_a1b2c3d4e5f6",
"language": "zh"
}
'import requests
url = "https://api.vivix.ai/v1/voices"
payload = {
"name": "Studio Host",
"file_id": "file_aud_a1b2c3d4e5f6",
"language": "zh"
}
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({name: 'Studio Host', file_id: 'file_aud_a1b2c3d4e5f6', language: 'zh'})
};
fetch('https://api.vivix.ai/v1/voices', 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",
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([
'name' => 'Studio Host',
'file_id' => 'file_aud_a1b2c3d4e5f6',
'language' => 'zh'
]),
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"
payload := strings.NewReader("{\n \"name\": \"Studio Host\",\n \"file_id\": \"file_aud_a1b2c3d4e5f6\",\n \"language\": \"zh\"\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")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Studio Host\",\n \"file_id\": \"file_aud_a1b2c3d4e5f6\",\n \"language\": \"zh\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.vivix.ai/v1/voices")
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 \"name\": \"Studio Host\",\n \"file_id\": \"file_aud_a1b2c3d4e5f6\",\n \"language\": \"zh\"\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "success",
"data": {
"voice_id": "voice_9f1c2a7b",
"name": "Studio Host",
"language": "zh"
}
}参考音频要求
参考音频要求
样本必须是最长 15 秒的连续清晰语音,格式为 16 位 WAV、MP3 或 M4A,采样率至少为 16 kHz。支持单声道或立体声;立体声只使用第一个声道。需要避免两种失败情况:
- 时间过长。 超过 15 秒的音频会在创建音色前被拒绝;API 返回 HTTP 400 和
20004。 - 时间过短或不包含语音。 极短的音频(约半秒以下)以及不包含真实语音的音频会被拒绝,因为服务必须先转录样本,并且要求存在转录文本。建议提供至少几秒钟的正常语音。该情况同样返回 HTTP 400 和
20004。
创建会话时使用音色
创建会话时使用音色
{
"pipeline_config": {
"tts_config": {
"tts_voice_id": "voice_9f1c2a7b"
}
}
}
tts_voice_id 设置为返回的音色 ID。该配置无需提供 provider 或 model 字段。错误
错误
错误响应使用相同的
{code, message, data} 封装;非零 code 表示具体错误。| 情况 | 错误码 |
|---|---|
缺少 name 或 file_id | 20003 missing required parameter |
language 或 name 无效 | 20004 invalid parameter |
file_id 不存在或不属于当前工作区 | 20005 not found |
file_id 不是音频文件 | 20004 invalid parameter |
| 样本超过 15 秒 | 20004 invalid parameter |
| 样本不包含可转写语音 | 20004 invalid parameter |
| 克隆服务商调用失败(HTTP 502) | 30007 voice clone provider failed |
达到音色配额 max_voices(HTTP 403) | 30010 voice clone quota exceeded |
| API 密钥缺失或无效 | 10001 missing api key 或 10003 invalid api key |
请求体
application/json