语音合成
声音克隆
对口型视频
其他
语音合成
声音克隆
对口型视频
其他
语音合成 (HTTP)
使用 HTTP 接口将文本转换为语音
语音合成接口
接口地址
POST /api/open/v1/speech/tts
请求头
// JSON 格式 Content-Type: application/json Authorization: Bearer YOUR_API_KEY // API Key // MessagePack 格式 Content-Type: application/msgpack Authorization: Bearer YOUR_API_KEY // API Key
请求参数
{
"voiceId": string, // 必填,音色 ID
"modelId": string, // 可选,模型版本 ID,如 fishaudio-s21pro-flash
"text": string, // 必填,要转换的文本
"speed": number, // 可选,语速,范围:0.5-2.0,默认:1
"volume": number, // 可选,音量,范围:-20-20,默认:0
"format": string, // 可选,音频格式。可选:"mp3"、"wav"、"pcm",默认:"mp3"
"emotion": string, // 可选,模型支持时生效
"language": string, // 可选,模型支持时生效
"cache": boolean // 可选,false 返回音频流,true 返回音频 URL,默认:false
}版本说明:
- • 传统版本:v1、v2、s1(基础语音合成功能)
- • V3版本:v3-turbo、v3-hd(支持情绪控制和语言增强等高级功能)
- • 系统会根据模型配置自动选择对应的版本,无需手动指定
返回数据
// 成功响应 (cache=false) - 200
Content-Type: audio/mpeg
<二进制音频数据>
// 成功响应 (cache=true) - 200
Content-Type: application/json
{
"success": boolean, // 是否成功
"audio_url": string, // 音频文件URL
"format": string, // 音频格式
"characters_used": number, // 使用的字符数
"quota_remaining": number // 剩余API积分
}
// 错误响应
{
"error": string // 错误提示信息
}CURL 示例
# JSON 格式 - 传统版本(使用 s1 版本,推荐)
curl -X POST https://kittaai.com/api/open/v1/speech/tts \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"voiceId": "your_voice_id",
"modelId": "fishaudio-s21pro-flash",
"text": "要转换的文本内容",
"speed": 1.0,
"volume": 0,
"format": "mp3",
"cache": false
}' \
--output output.mp3
# JSON 格式 - V3 模型(使用 HD 版本,支持情绪控制和语言增强)
curl -X POST https://kittaai.com/api/open/v1/speech/tts \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"voiceId": "your_voice_id",
"modelId": "minimax-2.8-hd",
"text": "要转换的文本内容",
"speed": 1.0,
"volume": 0,
"emotion": "calm",
"language": "zh",
"format": "mp3",
"cache": false
}' \
--output output.mp3
# MessagePack 格式 (undefined)在线调试
状态码说明
状态码说明:
200 OK - 请求成功
400 Bad Request - 请求参数错误
401 Unauthorized - API Key 无效
403 Forbidden - 禁止访问
404 Not Found - 资源不存在
413 Payload Too Large - 上传文件过大
429 Too Many Requests - 请求频率超限/积分不足
500 Server Error - 服务器内部错误
错误响应格式:
{
"error": string, // 错误信息
"details": string, // 详细错误信息(可选)
"code": string // 错误代码(可选)
}