API Reference
Text to speech API
Turn text into speech. The job is async and can be combined with voice cloning, avatars, and smart editing.
Overview
- 文本转语音
- 异步任务
- 回调 / 查询
- 可对接克隆音色
Use cases
- 口播配音
- 数字人驱动音频
- 有声内容生产
- Gateway ·
https://xiaoapis.com - Auth · send
key(query or JSON body, as this API specifies) - Response · JSON. Check the business code and the HTTP status, not only HTTP 200
Authentication
Send the platform API key (query parameter key or JSON field key, as this page specifies). Create one in API key management.
POST https://xiaoapis.com/api/aihuman/tts
Content-Type: application/json
{
"key": "YOUR_API_KEY"
}
Request example
https://xiaoapis.com/api/aihuman/tts?key=你的密钥
Details
请求HEADER:
| 名称 | 值 |
|---|---|
| Content-Type | application/json |
请求参数说明:
| 名称 | 必填 | 类型 | 示例值 | 说明 |
|---|---|---|---|---|
| text | 是 | string | 要克隆的文本内容 | 文本内容,不超过2000字 |
| voice_type | 否 | string | custom | 音色类型:克隆的音色custom、系统音色public |
| voice_id | 是 | string | 21221 | 克隆或系统的音色I |
| lang | 否 | string | zh-cn | 文本的语言,仅限克隆的音色。 默认值: zh-cn |
| volume | 否 | int | 1 | 音量,取值 0~2,默认 1 |
| speed | 否 | int | 1 | 语速,取值 0~2,默认 1 |
| notify | 是 | string | 回调地址,用于接收任务结果,任务结果数据会通过 POST 请求发送到该地址 |
返回参数说明:
| 名称 | 类型 | 说明 |
|---|---|---|
| code | int | 状态码 |
| msg | string | 状态信息 |
| data | string | 请求结果数据集 |
| - task_id | string | 任务id |
| debug | string/array | 调试数据 |
| exec_time | float | 执行耗时 |
| user_ip | string | 客户端IP |
回调的参数说明:
| 名称 | 类型 | 说明 |
|---|---|---|
| task_id | string | 任务id |
| code | int | 200 成功 |
| audio_url | string | 结果音频url(文件仅短暂留存,请转存) |
| msg | string | 失败原因,仅失败时有值 |
Response example
{ "code": 200, "data": { "task_id": "string" }, "msg": "string"}
FAQ
什么是语音合成 API?
语音合成 API(TTS)把输入文本转换成语音文件,供播放或作为数字人驱动音频。
TTS 怎么接入?
使用 API Key 调用创建接口,传入文案与音色相关参数,再通过查询或回调获取音频结果。
系统音色 voice_id 从哪拿?
调用公共音色列表接口获取,将 list[].voice_id 传入 TTS,并设置 voice_type=public。
可以用克隆的声音吗?
可以。先调用声音克隆拿到音色标识,再在 TTS 请求中按文档字段传入。
支持哪些语言?
以当前接口文档支持的语种参数为准;常见为中文等,具体见参数说明。
返回什么内容?
通常包含任务状态与音频地址等字段,部分能力可能附带字幕相关信息,以文档示例为准。
适合什么场景?
短视频口播、数字人出镜、自动化配音流水线与 Agent 成片。
Related APIs
Full console doc (with the debugger):/doc/10