使用已有的语音模型将文本转换为语音
POST /api/open/tts
// JSON 格式 Content-Type: application/json Authorization: Bearer YOUR_API_TOKEN // API密钥 // MessagePack 格式 Content-Type: application/msgpack Authorization: Bearer YOUR_API_TOKEN // API密钥
{ "reference_id": string, // 必填,模型ID "text": string, // 必填,要转换的文本 "speed": number, // 可选,语速,范围:0.5-2.0,默认:1 "volume": number, // 可选,音量,范围:-20-20,默认:0 "version": string // 可选,TTS版本,可选值:"v1"或"v2",默认:"v1" }
// 成功响应 - 200 Content-Type: audio/mpeg X-Characters-Used: number // 使用的字符数 X-Quota-Remaining: number // 剩余额度 <二进制音频数据> // 错误响应 { "error": string // 错误提示信息 }
# JSON 格式 curl -X POST https://fishspeech.net/api/open/tts \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d '{ "reference_id": "your_model_id", "text": "要转换的文本内容", "speed": 1.0, "volume": 0, "version": "v2" }' \ --output output.mp3 # MessagePack 格式 (需要使用支持 MessagePack 的客户端库)
状态码说明: 200 OK - 请求成功 400 Bad Request - 请求参数错误 401 Unauthorized - API Token 无效 403 Forbidden - 权限不足(非 Pro 用户) 404 Not Found - 资源不存在 413 Payload Too Large - 上传文件过大 429 Too Many Requests - 请求频率超限/额度不足 500 Server Error - 服务器内部错误 错误响应格式: { "error": string, // 错误信息 "details": string, // 详细错误信息(可选) "code": string // 错误代码(可选) }