跳转到内容

语音合成

基础信息

  • Base URL: https://api.ticos.cn
  • 合成音频: POST /tts
  • 查询音色: GET /tts

1. 合成音频(POST /tts)

请求头

  • Content-Type: application/json

请求参数

  • text(必填):要合成的文本内容
  • voice(可选):音色标识符
  • volume_ratio(可选):音量比例,取值范围 0-100(默认 50)
  • speed_ratio(可选):语速比例,取值范围 0-100(默认 50)
  • pitch_ratio(可选):音调比例,取值范围 0-100(默认 50)

请求示例

{
"voice": "zh_male_jingqiangkanye_moon_bigtts",
"text": "你好,这是一个例子文本。",
"volume_ratio": 50,
"speed_ratio": 50,
"pitch_ratio": 50
}

成功响应

  • 200 OK
  • Content-Type: audio/wav
  • 返回 WAV 音频字节流

错误响应

  • 400 Bad Request:缺少必填参数或 JSON 非法
  • 500 Internal Server Error:服务器内部错误

Curl 示例

curl --location 'https://api.ticos.cn/tts' \
--header 'Content-Type: application/json' \
--data-raw '{
"voice": "zh_male_jingqiangkanye_moon_bigtts",
"text": "你好,这是一个例子文本。",
"volume_ratio": 50,
"speed_ratio": 50,
"pitch_ratio": 50
}'

2. 查询可用音色(GET /tts)

常用查询参数

  • language:如 chinese、english
  • gender:male / female
  • name:按名称模糊匹配
  • provider:如 baidu、bytedance、aliyun
  • tags:按标签过滤,可用逗号分隔多个标签
  • all:true 返回完整字段,默认 false
  • skip:分页偏移(默认 0)
  • top:返回条数(默认 10)

响应示例

{
"code": 0,
"message": "Success",
"data": {
"speakers": [
{
"name": "音色名称",
"voice": "音色标识符"
}
],
"speakers_count": 10,
"total_speakers_count": 500
}
}

Curl 示例

# 前 5 个中文音色
curl "https://api.ticos.cn/tts?language=chinese&skip=0&top=5"
# 所有男性音色(完整字段)curl "https://api.ticos.cn/tts?gender=male&all=true"
# 组合过滤:字节跳动 + 中文 + 男声
curl "https://api.ticos.cn/tts?provider=bytedance&language=chinese&gender=male"