🔑 认证

所有API请求需要在Header中携带API Key。

Authorization: Bearer sk-xxxxxxxxxxxxxxxxxxxxxxxx

API Key可在注册后在控制台获取。

🎧 Playground

Playground使用预生成Demo。完整API支持任意文本实时合成。注册后可用。

📝 文字转语音

POST/v1/synthesize

参数类型必填说明
textstring最大5000字符
voicestringsage
speedfloat0.5-2.0,默认1.0
pitchfloat-20到+20,默认0
formatstringmp3 / wav
curl -X POST https://api.yoko.hk.cn/v1/synthesize \
  -H "Authorization: Bearer sk-xxx" \
  -H "Content-Type: application/json" \
  -d '{"text":"你好世界","voice":"sage"}' \
  --output output.mp3
import requests
resp = requests.post("https://api.yoko.hk.cn/v1/synthesize",
    headers={"Authorization":"Bearer sk-xxx"},
    json={"text":"你好世界","voice":"sage"})
with open("output.mp3","wb") as f: f.write(resp.content)

🎙️ 获取声音列表

GET/v1/voices

curl https://api.yoko.hk.cn/v1/voices -H "Authorization: Bearer sk-xxx"

📦 SDK

Python

pip install sevenlabs
from sevenlabs import Client
client = Client(api_key="sk-xxx")
audio = client.synthesize("你好世界", voice="sage")
for chunk in client.synthesize_stream("长文本...", voice="anchor"):
    play(chunk)

Node.js

npm install sevenlabs
import SevenLabs from 'sevenlabs';
const client = new SevenLabs({apiKey:'sk-xxx'});
const audio = await client.synthesize({text:'你好世界',voice:'sage'});