curl --request POST 'https://api.voicecheap.ai/v1/actions/tts_get' \
--header "x-api-key: $VOICECHEAP_API_KEY" \
--header 'Content-Type: application/json' \
--data '{"historyId":"722c80c6412edd4c3dcd625061e1c1feafbb0d54274d95fd8b5ca047f8cdd23d"}'
const input = {
historyId: '722c80c6412edd4c3dcd625061e1c1feafbb0d54274d95fd8b5ca047f8cdd23d',
};
const response = await fetch('https://api.voicecheap.ai/v1/actions/tts_get', {
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/tts_get",
headers={"x-api-key": os.environ["VOICECHEAP_API_KEY"]},
json={"historyId": "722c80c6412edd4c3dcd625061e1c1feafbb0d54274d95fd8b5ca047f8cdd23d"},
timeout=120,
)
body = response.json()
if not response.ok:
raise RuntimeError(f"{body.get('code')}: {body.get('message')}")
print(body)
{
"data": {
"historyId": "722c80c6412edd4c3dcd625061e1c1feafbb0d54274d95fd8b5ca047f8cdd23d",
"text": "Hello world.",
"spokenText": "Hello world.",
"voice": "933563129e564b19a115bedd57b7406a",
"voiceName": "Sarah",
"voiceSource": "catalog",
"inputType": "text",
"instructionPreset": "narrator",
"instructions": "Speak clearly and leave a short pause at the end.",
"speed": 1,
"sourceFileName": "launch-script.txt",
"characterCount": 12,
"durationSeconds": 1.5,
"previewEndIndex": null,
"createdAt": 1792152000000,
"updatedAt": 1792152000000,
"status": "success",
"audioUrl": "https://files.example.com/launch-script.mp3",
"wordAlignment": [
{
"text": "Hello",
"startSeconds": 0,
"endSeconds": 0.6,
"sourceStartCharacterIndex": 0,
"sourceEndCharacterIndex": 5
},
{
"text": "world.",
"startSeconds": 0.7,
"endSeconds": 1.4,
"sourceStartCharacterIndex": 6,
"sourceEndCharacterIndex": 12
}
]
}
}
文本转语音
获取已生成的语音
获取当前账户拥有的语音生成结果,包括文稿、表达设置、临时音频 URL 和可用的逐词对齐结果。
POST
/
v1
/
actions
/
tts_get
curl --request POST 'https://api.voicecheap.ai/v1/actions/tts_get' \
--header "x-api-key: $VOICECHEAP_API_KEY" \
--header 'Content-Type: application/json' \
--data '{"historyId":"722c80c6412edd4c3dcd625061e1c1feafbb0d54274d95fd8b5ca047f8cdd23d"}'
const input = {
historyId: '722c80c6412edd4c3dcd625061e1c1feafbb0d54274d95fd8b5ca047f8cdd23d',
};
const response = await fetch('https://api.voicecheap.ai/v1/actions/tts_get', {
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/tts_get",
headers={"x-api-key": os.environ["VOICECHEAP_API_KEY"]},
json={"historyId": "722c80c6412edd4c3dcd625061e1c1feafbb0d54274d95fd8b5ca047f8cdd23d"},
timeout=120,
)
body = response.json()
if not response.ok:
raise RuntimeError(f"{body.get('code')}: {body.get('message')}")
print(body)
{
"data": {
"historyId": "722c80c6412edd4c3dcd625061e1c1feafbb0d54274d95fd8b5ca047f8cdd23d",
"text": "Hello world.",
"spokenText": "Hello world.",
"voice": "933563129e564b19a115bedd57b7406a",
"voiceName": "Sarah",
"voiceSource": "catalog",
"inputType": "text",
"instructionPreset": "narrator",
"instructions": "Speak clearly and leave a short pause at the end.",
"speed": 1,
"sourceFileName": "launch-script.txt",
"characterCount": 12,
"durationSeconds": 1.5,
"previewEndIndex": null,
"createdAt": 1792152000000,
"updatedAt": 1792152000000,
"status": "success",
"audioUrl": "https://files.example.com/launch-script.mp3",
"wordAlignment": [
{
"text": "Hello",
"startSeconds": 0,
"endSeconds": 0.6,
"sourceStartCharacterIndex": 0,
"sourceEndCharacterIndex": 5
},
{
"text": "world.",
"startSeconds": 0.7,
"endSeconds": 1.4,
"sourceStartCharacterIndex": 6,
"sourceEndCharacterIndex": 12
}
]
}
}
获取当前账户拥有的语音生成结果,包括文稿、表达设置、临时音频 URL 和可用的逐词对齐结果。
所需权限:
POST https://api.voicecheap.ai/v1/actions/tts_get
身份验证和权限
string
必填
在此请求头中发送 VoiceCheap API 密钥。也支持通过 Authorization: Bearer 发送同一 API 密钥。OAuth 访问令牌仅适用于 MCP,此 REST 端点不接受 OAuth
访问令牌。
tts:read.
需要有效的付费订阅。权限不会改变团队角色、资源归属、媒体额度或套餐限制。
参数
string
必填
由 tts_generate 或 tts_list 返回的历史记录 ID。匹配模式:
^(free-)?[0-9a-f]{64}$.完整输入架构
完整输入架构
以下 JSON Schema 保留了发现接口公开的确切字段名、嵌套类型、默认值、范围和可接受值。其他跨字段规则列于操作说明中。
{
"type": "object",
"properties": {
"historyId": {
"type": "string",
"pattern": "^(free-)?[0-9a-f]{64}$",
"description": "History ID returned by tts_generate or tts_list."
}
},
"required": ["historyId"],
"additionalProperties": false
}
请求示例
请将示例资源标识符和媒体键替换为账户返回的值。重试同一次修改操作时,请保持请求标识符不变。curl --request POST 'https://api.voicecheap.ai/v1/actions/tts_get' \
--header "x-api-key: $VOICECHEAP_API_KEY" \
--header 'Content-Type: application/json' \
--data '{"historyId":"722c80c6412edd4c3dcd625061e1c1feafbb0d54274d95fd8b5ca047f8cdd23d"}'
const input = {
historyId: '722c80c6412edd4c3dcd625061e1c1feafbb0d54274d95fd8b5ca047f8cdd23d',
};
const response = await fetch('https://api.voicecheap.ai/v1/actions/tts_get', {
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/tts_get",
headers={"x-api-key": os.environ["VOICECHEAP_API_KEY"]},
json={"historyId": "722c80c6412edd4c3dcd625061e1c1feafbb0d54274d95fd8b5ca047f8cdd23d"},
timeout=120,
)
body = response.json()
if not response.ok:
raise RuntimeError(f"{body.get('code')}: {body.get('message')}")
print(body)
响应
首次执行成功时返回 HTTP 200,操作结果位于 data 下。重放请求时可能改为返回已保存的请求状态。示例展示了一种支持的响应,并未包含所有可选字段。 当前账户拥有的语音历史详情、完整的可编辑脚本和口述脚本、语音表达设置、临时播放 URL,以及所有可用的单词时间戳。{
"data": {
"historyId": "722c80c6412edd4c3dcd625061e1c1feafbb0d54274d95fd8b5ca047f8cdd23d",
"text": "Hello world.",
"spokenText": "Hello world.",
"voice": "933563129e564b19a115bedd57b7406a",
"voiceName": "Sarah",
"voiceSource": "catalog",
"inputType": "text",
"instructionPreset": "narrator",
"instructions": "Speak clearly and leave a short pause at the end.",
"speed": 1,
"sourceFileName": "launch-script.txt",
"characterCount": 12,
"durationSeconds": 1.5,
"previewEndIndex": null,
"createdAt": 1792152000000,
"updatedAt": 1792152000000,
"status": "success",
"audioUrl": "https://files.example.com/launch-script.mp3",
"wordAlignment": [
{
"text": "Hello",
"startSeconds": 0,
"endSeconds": 0.6,
"sourceStartCharacterIndex": 0,
"sourceEndCharacterIndex": 5
},
{
"text": "world.",
"startSeconds": 0.7,
"endSeconds": 1.4,
"sourceStartCharacterIndex": 6,
"sourceEndCharacterIndex": 12
}
]
}
}
结果字段
| 字段 | 说明 |
|---|---|
data.historyId | 当前账户拥有的语音历史记录 ID:64 个小写十六进制字符,应用内预览可带 free- 前缀。 |
data.voice | 原始 TTS 选择 ID,已保存的自定义音色包含 clone:<UUID>。 |
data.voiceName | 所选音色的已保存显示名称,可选。 |
data.voiceSource | 可选的音色来源:catalog 或 clone。 |
data.inputType | 原始输入类型:text 或 pdf。 |
data.instructionPreset | 已存储的表达预设。 |
data.sourceFileName | 生成时提供的可选原始文件名。 |
data.characterCount | 此次语音生成记录的字符数。 |
data.durationSeconds | 音频时长,以秒为单位。 |
data.createdAt | 创建时间,采用 Unix 毫秒时间戳。 |
data.updatedAt | 最后更新时间,采用 Unix 毫秒时间戳。 |
data.status | 已存储的成功语音条目使用 success;tts_generate 在其生成结果中使用 completed。 |
data.text | 完整且可编辑的已存储文稿,包括支持的表达控制标签。 |
data.spokenText | 已存储的文稿,其中支持的表达控制标签已移除。 |
data.instructions | 已存储的自定义表达指令;未设置时为空。 |
data.speed | 已存储的播放表达速度;旧记录未包含此值时为 1。 |
data.previewEndIndex | 可用预览的字符边界;完整音频为 null。 |
data.audioUrl | 可播放的临时音频 URL。 |
data.wordAlignment | 单词时间戳;没有可用对齐数据时为 null。 |
data.wordAlignment[].text | 对齐后的单词文本。 |
data.wordAlignment[].startSeconds | 单词开始时间,单位为秒。 |
data.wordAlignment[].endSeconds | 词语结束时间,单位为秒。 |
data.wordAlignment[].sourceStartCharacterIndex | 移除语音表达控制标签后,spokenText 中的起始字符索引。 |
data.wordAlignment[].sourceEndCharacterIndex | 移除表达控制标签后,spokenText 中的结束字符索引。 |
操作说明
- historyId 必须为 64 个小写十六进制字符,可带 free- 前缀。请使用 tts_generate 或 tts_list 返回的标识符。
- voiceName、voiceSource 和 sourceFileName 等旧记录中的可选属性可能被省略。缺失的 instructions 默认为空字符串,缺失的 speed 默认为 1,缺失的 previewEndIndex 默认为 null。
- wordAlignment 可以为 null。此读取操作加载现有对齐结果;使用 tts_align 准备时间戳。
- wordAlignment 中的源字符索引指向已移除语音表达控制标签的 spokenText。
- audioUrl 为临时 URL。再次调用 tts_get 获取新的播放地址,或调用 tts_download 获取下载链接。
- 语音历史记录和自定义音色归已认证账户所有。使用团队计费并不授予访问其他成员语音或音色的权限。
用量
每次成功调用消耗一次月度 API/MCP 调用额度。媒体额度和操作本身的生成限额也适用。错误
| HTTP 状态 | 代码 | 含义或恢复方式 |
|---|---|---|
| 400 | CREDENTIAL_IN_QUERY | 凭证通过 access_token 或 api_key 查询参数提供。请在标头中发送凭证。 |
| 400 | VALIDATION_ERROR | 输入不符合操作架构;请查看 details 了解字段错误。 |
| 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 | AMBIGUOUS_TEAM_API_KEY | 此凭据对应的用户属于多个团队,因此计费上下文不明确。 |
| 403 | INSUFFICIENT_SCOPE | 请授予全部所需权限,或选择其他凭据。 |
| 403 | INTEGRATION_PLAN_UNSUPPORTED | 无法验证该账户的集成限制。 |
| 403 | SUBSCRIPTION_REQUIRED | 请使用有效的付费订阅。 |
| 403 | TEAM_OWNER_NOT_FOUND | 找不到实际生效的团队所有者账户。 |
| 404 | TEXT_TO_SPEECH_HISTORY_NOT_FOUND | 语音历史条目不存在,或属于其他账户。 |
| 429 | INTEGRATION_MONTHLY_LIMIT_REACHED | 请等待月度额度重置,或更改套餐。 |
| 429 | INTEGRATION_RATE_LIMIT_REACHED | 如果提供了 Retry-After,请等待其指定的时间,并采用退避重试。 |
| 500 | INTERNAL_ERROR | 在决定是否重试修改操作前,请检查已保存的请求状态和资源历史记录。 |
| 503 | SERVER_RESTARTING | 服务器正在重启。请稍后重试;对于修改操作,请保持请求标识符不变。 |
{
"code": "INSUFFICIENT_SCOPE",
"message": "This credential does not permit the requested action.",
"status": 403,
"details": {
"requiredScopes": ["tts:read"]
}
}
此页面对您有帮助吗?

