🔑 认证
所有API请求需要在Header中携带API Key。
Authorization: Bearer sk-xxxxxxxxxxxxxxxxxxxxxxxx
API Key可在注册后在控制台获取。
🎧 Playground
Playground使用预生成Demo。完整API支持任意文本实时合成。注册后可用。
📝 文字转语音
POST/v1/synthesize
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
text | string | 是 | 最大5000字符 |
voice | string | 是 | 如 sage |
speed | float | 否 | 0.5-2.0,默认1.0 |
pitch | float | 否 | -20到+20,默认0 |
format | string | 否 | mp3 / 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.mp3import 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'});