Seed Audio

音频模型的接口跟官方一模一样,照官方文档写好的代码,只换地址和 Key 就能用。不走 /v1/chat/completions。

快速接入

官方 换成

地址 https://openspeech.bytedance.com/api/v3/tts/create https://www.acctoken.com/api/v3/tts/create

Key X-Api-Key:官方的 Key X-Api-Key:本站控制台的 API Key

这是同步接口:音频生成好才返回,超时设长一点(官方示例是 300 秒)。

import base64, requests

URL = "https://www.acctoken.com/api/v3/tts/create"   # 官方是 https://openspeech.bytedance.com/api/v3/tts/create,只换这一行和下面的 Key
headers = {"Content-Type": "application/json", "X-Api-Key": "<YOUR_API_KEY>"}
payload = {
    "model": "seed-audio-1.0",
    "text_prompt": "一段温暖的旁白,欢迎大家来到新的一年。",
    "audio_config": {"format": "mp3", "sample_rate": 48000},
}

response = requests.post(URL, headers=headers, json=payload, timeout=300)
response.raise_for_status()
result = response.json()
with open("out.mp3", "wb") as f:
    f.write(base64.b64decode(result["audio"]))
print(result["original_duration"], "秒")  # 计费时长
curl https://www.acctoken.com/api/v3/tts/create \
  --max-time 300 \
  -H "X-Api-Key: <YOUR_API_KEY>" \
  -H "Content-Type: application/json" \
  -o out.json \
  -d @- <<'EOF'
{
  "model": "seed-audio-1.0",
  "text_prompt": "一段温暖的旁白,欢迎大家来到新的一年。",
  "audio_config": {"format": "mp3", "sample_rate": 48000}
}
EOF

从 -d @- 到 EOF 整段一起粘进终端,Windows 的 Git Bash 里中文才不会乱码。

回包

字段 说明

audio 音频的 Base64

duration 时长(秒)

original_duration 计费时长(秒),单次最多 120,倍速不影响

url 音频链接,2 小时有效

subtitle 字幕,打开 enable_subtitle 才有

失败时 HTTP 不是 200,怎么查见报错对照。

计费

按 original_duration 折算成分钟,不足一分钟按秒折算;单价看模型详情页。

交单时先按 120 秒预扣,出结果后按实际时长退回;余额不够这个数,这一单不会开始。

失败不扣费。超过 120 秒的(正常语速约 600 字)不收,报错见报错对照。

跟官方不一样的地方

项 说明

Key 的位置 只认请求头,不认地址里的查询参数

同时进行 每个账号最多 2 单,超了回 429(见报错对照)

X-Api-Request-Id 可以照传,但不会原样转给官方,也不写进回包