POST
/v1/audio/speech文本转语音
将文本转换为自然语音,支持多种语音模型和音色。
请求地址
POST https://token.wlj.weifaner.net:8001/v1/audio/speech请求头
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
Authorization | string | 是 | Bearer Token 认证 |
Content-Type | string | 是 | application/json |
请求体
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 语音模型,如 tts-1, tts-1-hd |
input | string | 是 | 要转换的文本内容 |
voice | string | 是 | 音色:alloy, echo, fable, onyx, nova, shimmer |
response_format | string | 否 | 输出格式:mp3, opus, aac, flac(默认 mp3) |
speed | number | 否 | 语速,范围 0.25-4.0(默认 1.0) |
请求示例
curl -X POST https://token.wlj.weifaner.net:8001/v1/audio/speech \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "tts-1",
"input": "你好,这是文本转语音的示例。",
"voice": "alloy",
"response_format": "mp3",
"speed": 1.0
}' \
--output speech.mp3响应说明
响应为音频文件二进制流,Content-Type 根据 response_format 参数返回对应的音频格式。
最后更新于 2026/5/25