curl --request POST 'https://api.voicecheap.ai/v1/actions/dubbing_voices_clone' \
--header "x-api-key: $VOICECHEAP_API_KEY" \
--header 'Content-Type: application/json' \
--data '{"requestId":"284a861a-4da8-4d67-ad48-8123e76c8e91","name":"Studio narrator","fileKey":"uploads/example-user/66666666-6666-4666-8666-666666666666-narrator.wav","hasPermission":true}'
const input = {
requestId: '284a861a-4da8-4d67-ad48-8123e76c8e91',
name: 'Studio narrator',
fileKey: 'uploads/example-user/66666666-6666-4666-8666-666666666666-narrator.wav',
hasPermission: true,
};
const response = await fetch('https://api.voicecheap.ai/v1/actions/dubbing_voices_clone', {
method: 'POST',
headers: {
'x-api-key': process.env.VOICECHEAP_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify(input),
});
const body = await response.json();
if (!response.ok) throw new Error(body.code + ': ' + body.message);
console.log(body);
import os
import requests
response = requests.post(
"https://api.voicecheap.ai/v1/actions/dubbing_voices_clone",
headers={"x-api-key": os.environ["VOICECHEAP_API_KEY"]},
json={"requestId": "284a861a-4da8-4d67-ad48-8123e76c8e91", "name": "Studio narrator", "fileKey": "uploads/example-user/66666666-6666-4666-8666-666666666666-narrator.wav", "hasPermission": True},
timeout=120,
)
body = response.json()
if not response.ok:
raise RuntimeError(f"{body.get('code')}: {body.get('message')}")
print(body)
{
"data": {
"requestId": "284a861a-4da8-4d67-ad48-8123e76c8e91",
"status": "running",
"pollAction": "action_request_get",
"pollAfterSeconds": 5
},
"requestId": "284a861a-4da8-4d67-ad48-8123e76c8e91"
}
{
"data": {
"id": "dubbing_voice_R8q3k9Yp",
"name": "Studio narrator",
"audioExampleUrl": "https://files.example.com/dubbing-narrator.mp3"
},
"requestId": "284a861a-4da8-4d67-ad48-8123e76c8e91"
}
{
"data": {
"requestId": "284a861a-4da8-4d67-ad48-8123e76c8e91",
"operation": "dubbing_voices_clone",
"createdAt": 1792144800000,
"updatedAt": 1792144820000,
"status": "running",
"pollAfterSeconds": 5
},
"requestId": "284a861a-4da8-4d67-ad48-8123e76c8e91"
}
{
"data": {
"requestId": "284a861a-4da8-4d67-ad48-8123e76c8e91",
"operation": "dubbing_voices_clone",
"createdAt": 1792144800000,
"updatedAt": 1792144820000,
"status": "completed",
"resultStored": false,
"message": "The action completed. Retrieve its output from the corresponding history or resource action."
},
"requestId": "284a861a-4da8-4d67-ad48-8123e76c8e91"
}
配音音色
克隆配音音色
使用当前账户拥有、已上传且获得明确授权的音频样本,创建并保存自定义视频配音音色。受应用的自定义音色数量限制,并包含音频示例。请复用 requestId,避免重复创建。
POST
/
v1
/
actions
/
dubbing_voices_clone
curl --request POST 'https://api.voicecheap.ai/v1/actions/dubbing_voices_clone' \
--header "x-api-key: $VOICECHEAP_API_KEY" \
--header 'Content-Type: application/json' \
--data '{"requestId":"284a861a-4da8-4d67-ad48-8123e76c8e91","name":"Studio narrator","fileKey":"uploads/example-user/66666666-6666-4666-8666-666666666666-narrator.wav","hasPermission":true}'
const input = {
requestId: '284a861a-4da8-4d67-ad48-8123e76c8e91',
name: 'Studio narrator',
fileKey: 'uploads/example-user/66666666-6666-4666-8666-666666666666-narrator.wav',
hasPermission: true,
};
const response = await fetch('https://api.voicecheap.ai/v1/actions/dubbing_voices_clone', {
method: 'POST',
headers: {
'x-api-key': process.env.VOICECHEAP_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify(input),
});
const body = await response.json();
if (!response.ok) throw new Error(body.code + ': ' + body.message);
console.log(body);
import os
import requests
response = requests.post(
"https://api.voicecheap.ai/v1/actions/dubbing_voices_clone",
headers={"x-api-key": os.environ["VOICECHEAP_API_KEY"]},
json={"requestId": "284a861a-4da8-4d67-ad48-8123e76c8e91", "name": "Studio narrator", "fileKey": "uploads/example-user/66666666-6666-4666-8666-666666666666-narrator.wav", "hasPermission": True},
timeout=120,
)
body = response.json()
if not response.ok:
raise RuntimeError(f"{body.get('code')}: {body.get('message')}")
print(body)
{
"data": {
"requestId": "284a861a-4da8-4d67-ad48-8123e76c8e91",
"status": "running",
"pollAction": "action_request_get",
"pollAfterSeconds": 5
},
"requestId": "284a861a-4da8-4d67-ad48-8123e76c8e91"
}
{
"data": {
"id": "dubbing_voice_R8q3k9Yp",
"name": "Studio narrator",
"audioExampleUrl": "https://files.example.com/dubbing-narrator.mp3"
},
"requestId": "284a861a-4da8-4d67-ad48-8123e76c8e91"
}
{
"data": {
"requestId": "284a861a-4da8-4d67-ad48-8123e76c8e91",
"operation": "dubbing_voices_clone",
"createdAt": 1792144800000,
"updatedAt": 1792144820000,
"status": "running",
"pollAfterSeconds": 5
},
"requestId": "284a861a-4da8-4d67-ad48-8123e76c8e91"
}
{
"data": {
"requestId": "284a861a-4da8-4d67-ad48-8123e76c8e91",
"operation": "dubbing_voices_clone",
"createdAt": 1792144800000,
"updatedAt": 1792144820000,
"status": "completed",
"resultStored": false,
"message": "The action completed. Retrieve its output from the corresponding history or resource action."
},
"requestId": "284a861a-4da8-4d67-ad48-8123e76c8e91"
}
使用当前账户拥有、已上传且获得明确授权的音频样本,创建并保存自定义视频配音音色。受应用的自定义音色数量限制,并包含音频示例。请复用 requestId,避免重复创建。
所需权限:
POST https://api.voicecheap.ai/v1/actions/dubbing_voices_clone
身份验证和权限
string
必填
在此请求头中发送 VoiceCheap API 密钥。也支持通过 Authorization: Bearer 发送同一 API 密钥。OAuth 访问令牌仅适用于 MCP,此 REST 端点不接受 OAuth
访问令牌。
voices:write.
需要有效的付费订阅。权限不会改变团队角色、资源归属、媒体额度或套餐限制。
参数
string
在传输层可选:如果省略,服务器会在验证前注入标识符。请自行提供稳定的 UUID v4,以便在响应丢失后安全恢复。格式: “uuid”. 匹配模式:
^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$.string
必填
文本值。最小长度: 1. 最大长度: 80.
string
必填
文本值。最小长度: 1. 最大长度: 1024.
boolean
必填
布尔值。指定值: true.
完整输入架构
完整输入架构
以下 JSON Schema 保留了发现接口公开的确切字段名、嵌套类型、默认值、范围和可接受值。其他跨字段规则列于操作说明中。
{
"type": "object",
"properties": {
"requestId": {
"type": "string",
"format": "uuid",
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
"description": "UUID v4 for this action. Reuse the same ID with identical arguments on retries."
},
"name": {
"type": "string",
"minLength": 1,
"maxLength": 80
},
"fileKey": {
"type": "string",
"minLength": 1,
"maxLength": 1024
},
"hasPermission": {
"type": "boolean",
"const": true
}
},
"required": ["name", "fileKey", "hasPermission"],
"additionalProperties": false
}
幂等性
为每次修改操作在 requestId 或 Idempotency-Key HTTP 请求头中提供 UUID v4。网络故障后,请使用相同标识符和完全相同的参数重试。如果同时提供这两个值,它们必须一致。重放已保存的请求不会重复执行操作,也不会再次扣除月度调用次数。失败或中断的请求不会自动重新执行。 对于每次修改操作,如果重试时发现同一请求仍在运行,即使首次执行通常为同步操作,也可能返回 HTTP 202。如果执行已完成但 resultStored 为 false,重试会返回 HTTP 200 和已保存的请求状态,而非原始结果。请通过对应领域的历史记录、结果或下载操作获取输出。请求示例
请将示例资源标识符和媒体键替换为账户返回的值。重试同一次修改操作时,请保持请求标识符不变。curl --request POST 'https://api.voicecheap.ai/v1/actions/dubbing_voices_clone' \
--header "x-api-key: $VOICECHEAP_API_KEY" \
--header 'Content-Type: application/json' \
--data '{"requestId":"284a861a-4da8-4d67-ad48-8123e76c8e91","name":"Studio narrator","fileKey":"uploads/example-user/66666666-6666-4666-8666-666666666666-narrator.wav","hasPermission":true}'
const input = {
requestId: '284a861a-4da8-4d67-ad48-8123e76c8e91',
name: 'Studio narrator',
fileKey: 'uploads/example-user/66666666-6666-4666-8666-666666666666-narrator.wav',
hasPermission: true,
};
const response = await fetch('https://api.voicecheap.ai/v1/actions/dubbing_voices_clone', {
method: 'POST',
headers: {
'x-api-key': process.env.VOICECHEAP_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify(input),
});
const body = await response.json();
if (!response.ok) throw new Error(body.code + ': ' + body.message);
console.log(body);
import os
import requests
response = requests.post(
"https://api.voicecheap.ai/v1/actions/dubbing_voices_clone",
headers={"x-api-key": os.environ["VOICECHEAP_API_KEY"]},
json={"requestId": "284a861a-4da8-4d67-ad48-8123e76c8e91", "name": "Studio narrator", "fileKey": "uploads/example-user/66666666-6666-4666-8666-666666666666-narrator.wav", "hasPermission": True},
timeout=120,
)
body = response.json()
if not response.ok:
raise RuntimeError(f"{body.get('code')}: {body.get('message')}")
print(body)
响应
此操作在运行期间返回 HTTP 202。请保存 requestId,并使用该标识符和原始操作名称轮询 action_request_get。轮询状态包括 running、completed、failed 和 interrupted。已完成的结果可能指向独立的媒体任务;请继续使用该操作对应的状态或输出操作。 已保存的自定义配音音色,包括其 ID、名称和可选的音频示例。不包含 TTS 风格的 voice 或 cloneUsage 外层结构。{
"data": {
"requestId": "284a861a-4da8-4d67-ad48-8123e76c8e91",
"status": "running",
"pollAction": "action_request_get",
"pollAfterSeconds": 5
},
"requestId": "284a861a-4da8-4d67-ad48-8123e76c8e91"
}
{
"data": {
"id": "dubbing_voice_R8q3k9Yp",
"name": "Studio narrator",
"audioExampleUrl": "https://files.example.com/dubbing-narrator.mp3"
},
"requestId": "284a861a-4da8-4d67-ad48-8123e76c8e91"
}
{
"data": {
"requestId": "284a861a-4da8-4d67-ad48-8123e76c8e91",
"operation": "dubbing_voices_clone",
"createdAt": 1792144800000,
"updatedAt": 1792144820000,
"status": "running",
"pollAfterSeconds": 5
},
"requestId": "284a861a-4da8-4d67-ad48-8123e76c8e91"
}
{
"data": {
"requestId": "284a861a-4da8-4d67-ad48-8123e76c8e91",
"operation": "dubbing_voices_clone",
"createdAt": 1792144800000,
"updatedAt": 1792144820000,
"status": "completed",
"resultStored": false,
"message": "The action completed. Retrieve its output from the corresponding history or resource action."
},
"requestId": "284a861a-4da8-4d67-ad48-8123e76c8e91"
}
结果字段
| 字段 | 说明 |
|---|---|
data.id | 已保存的配音音色的不透明 ID。 |
data.name | 已保存音色的显示名称。 |
data.audioExampleUrl | 可选的可播放示例音频 URL。列表和详情响应将其作为 previewUrl 返回。 |
恢复并轮询此请求
即使连接丢失,也应使用同一标识符。如果 resultStored 为 false,请通过相应的历史记录、结果或下载操作获取输出。切勿仅为查看进度而启动第二次生成。curl --request POST 'https://api.voicecheap.ai/v1/actions/action_request_get' \
--header "x-api-key: $VOICECHEAP_API_KEY" \
--header 'Content-Type: application/json' \
--data '{"requestId":"284a861a-4da8-4d67-ad48-8123e76c8e91","operation":"dubbing_voices_clone"}'
HTTP 200
{
"data": {
"requestId": "284a861a-4da8-4d67-ad48-8123e76c8e91",
"operation": "dubbing_voices_clone",
"status": "completed",
"createdAt": 1792144800000,
"updatedAt": 1792144820000,
"resultStored": true,
"result": {
"id": "dubbing_voice_R8q3k9Yp",
"name": "Studio narrator",
"audioExampleUrl": "https://files.example.com/dubbing-narrator.mp3"
}
}
}
操作说明
- 为此写入操作使用 UUID v4 格式的 requestId,重试时使用相同参数复用该 ID。长时间运行的操作首先返回 running 请求;此示例是可通过 action_request_get 获取的已完成处理程序结果。
- 此操作接受一个当前账户拥有的已完成音频上传,并要求 hasPermission: true 为 JSON 布尔值。不接受远程 URL 或其他账户的 fileKey。
- 支持的样本扩展名为 AAC、AC3、EAC3、FLAC、M4A、X-M4A、MP2、MP3、OGG 和 WAV。文件必须是非空且可读取的音频,符合套餐上传限额,且最大为 250,000,000 字节(250 MB)。
- 专用的 voicesupload* 系列限制更严格:仅接受 MP3、WAV、M4A、OGG 或 Opus,每次上传最大为 20 MiB。该上传系列接受的文件仍必须符合此配音操作支持的样本类型;此处不支持 Opus。
- name 去除首尾空白后需包含 1–80 个字符,且不能包含控制字符。
- TTS 音色克隆的合并样本 10–120 秒规则不适用于此操作。其样本必须能读取到大于零的时长,且不得超过 45 分钟;音频不会被自动裁剪至该上限。
- 使用账户已保存的自定义配音音色名额限额。调用 dubbing_voices_list 以获取更新后的 cloneUsage;克隆结果本身不包含该字段。
- 使用返回的不透明 id 进行配音。它没有 clone: 前缀,不能用作 TTS 音色选项。
- 语音历史记录和自定义音色归已认证账户所有。使用团队计费并不授予访问其他成员语音或音色的权限。
用量
每次成功调用消耗一次月度 API/MCP 调用额度。媒体额度和操作本身的生成限额也适用。错误
| HTTP 状态 | 代码 | 含义或恢复方式 |
|---|---|---|
| 400 | BAD_REQUEST | 样本没有可读取的正时长、超过配音克隆的 45 分钟时长上限,或因过长被拒绝。 |
| 400 | CREDENTIAL_IN_QUERY | 凭证通过 access_token 或 api_key 查询参数提供。请在标头中发送凭证。 |
| 400 | IDEMPOTENCY_CONFLICT | Idempotency-Key 请求头必须与请求体中的 requestId 字段一致。 |
| 400 | INVALID_REQUEST_ID | 请在 requestId 或 Idempotency-Key 中提供 UUID v4。 |
| 400 | VALIDATION_ERROR | 输入不符合操作架构;请查看 details 了解字段错误。 |
| 400 | VOICE_NAME_INVALID | 名称为空、过长或包含控制字符。 |
| 400 | VOICE_SAMPLE_INVALID_SIZE | 样本为空、实际字节数与声明的大小不一致,或超过当前套餐上限或 250 MB。 |
| 400 | VOICE_SAMPLE_INVALID_TYPE | 样本文件名不是受支持的配音音频格式。 |
| 400 | VOICE_SAMPLE_NOT_OWNED | 上传的样本不安全,或不属于已认证账户。 |
| 401 | API_KEY_EXPIRED | API 密钥已过期。 |
| 401 | INVALID_API_KEY | 请提供有效且未过期的 API 密钥。 |
| 401 | INVALID_CREDENTIAL | Authorization 标头格式错误或与 x-api-key 冲突。 |
| 401 | MISSING_CREDENTIAL | 未提供可用的请求头凭据,或其长度超过 4096 个字符。 |
| 401 | USER_NOT_FOUND | 该凭据对应的账户已不存在。 |
| 403 | ACCOUNT_UNAVAILABLE | 调用者账户或计费账户不可用,或正在删除。 |
| 403 | AMBIGUOUS_TEAM_API_KEY | 此凭据对应的用户属于多个团队,因此计费上下文不明确。 |
| 403 | INSUFFICIENT_SCOPE | 请授予全部所需权限,或选择其他凭据。 |
| 403 | INTEGRATION_PLAN_UNSUPPORTED | 无法验证该账户的集成限制。 |
| 403 | SUBSCRIPTION_REQUIRED | 请使用有效的付费订阅。 |
| 403 | TEAM_OWNER_NOT_FOUND | 找不到实际生效的团队所有者账户。 |
| 409 | CONCURRENT_ACTION_LIMIT_REACHED | 此账户已有 10 个集成操作正在运行。请先轮询现有请求,再启动另一个操作。 |
| 409 | DUBBING_VOICE_LIMIT_REACHED | 所有已保存自定义配音音色槽位均已占用。 |
| 409 | IDEMPOTENCY_CONFLICT | 此 requestId 已用于不同的配音音色输入。 |
| 409 | VOICE_MUTATION_IN_PROGRESS | 此账户的另一个配音音色写入操作正在运行。 |
| 409 | VOICE_MUTATION_LEASE_LOST | 该变更操作已失去执行权。重试前请检查请求状态和已保存的音色。 |
| 409 | VOICE_REQUEST_ALREADY_STARTED | 此音色请求此前已启动,但尚无确认的最终结果。启动另一请求前,请列出音色并检查请求状态。 |
| 429 | INTEGRATION_MONTHLY_LIMIT_REACHED | 请等待月度额度重置,或更改套餐。 |
| 429 | INTEGRATION_RATE_LIMIT_REACHED | 如果提供了 Retry-After,请等待其指定的时间,并采用退避重试。 |
| 500 | INTERNAL_ERROR | 无法完成音色操作。启动新的更改操作前,请检查请求状态和已保存的音色。 |
| 502 | INTERNAL_ERROR | 无法完成操作或确认其结果。启动另一次生成前,请检查请求状态和资源历史记录。 |
| 503 | ACTION_RESULT_UNAVAILABLE | 操作已执行,但未能保存结果。在启动新的生成前,请检查已保存的请求状态和资源历史记录。 |
| 503 | SERVER_RESTARTING | 服务器正在重启。请稍后重试;对于修改操作,请保持请求标识符不变。 |
{
"code": "INSUFFICIENT_SCOPE",
"message": "This credential does not permit the requested action.",
"status": 403,
"details": {
"requiredScopes": ["voices:write"]
}
}
此页面对您有帮助吗?

