Skip to content
Platform / Docs / Text to speech API

API Reference

Text to speech API

POST ai-voice-api ID 10

Turn text into speech. The job is async and can be combined with voice cloning, avatars, and smart editing.

POST https://xiaoapis.com/api/aihuman/tts

Overview

  • 文本转语音
  • 异步任务
  • 回调 / 查询
  • 可对接克隆音色

Use cases

  • 口播配音
  • 数字人驱动音频
  • 有声内容生产
Conventions
  • 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否stringcustom


音色类型:克隆的音色custom、系统音色public



voice_id是string21221


克隆或系统的音色I



lang否string zh-cn

文本的语言,仅限克隆的音色。
zh-cn:中文
en:英文
fr:法语
de:德语
ja:日语
ko:韩语
ru:俄语
pt:葡萄牙语
th:泰语
id:印尼语
vi:越南语

默认值: zh-cn

volume否int1

音量,取值 0~2,默认 1

speed否int1

语速,取值 0~2,默认 1

notify是string


回调地址,用于接收任务结果,任务结果数据会通过 POST 请求发送到该地址


返回参数说明:


名称类型说明
codeint状态码
msgstring状态信息
datastring请求结果数据集
- task_idstring任务id
debugstring/array调试数据
exec_timefloat执行耗时
user_ipstring客户端IP



回调的参数说明:

名称类型说明
task_idstring

任务id

codeint
200 成功
audio_urlstring

结果音频url(文件仅短暂留存,请转存)

msgstring


失败原因,仅失败时有值






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 成片。

Full console doc (with the debugger):/doc/10