文本转语音
文本转语音
将 Agent 输出的文字,转为语音播放。
请求方式
POST
调用地址
https://api-${endpoint}.gptbots.ai/v1/text-to-audio
调用验证
详情参见 API 概述的鉴权方式说明。
请求
请求示例
curl -X POST 'https://api-${endpoint}.gptbots.ai/v1/text-to-audio' \
-H 'Authorization: Bearer ${API Key}' \
-H 'Content-Type: application/json' \
-d '{
"id": "消息id"
}'
curl -X POST 'https://api-${endpoint}.gptbots.ai/v1/text-to-audio' \
-H 'Authorization: Bearer ${API Key}' \
-H 'Content-Type: application/json' \
-d '{
"id": "消息id"
}'
此代碼塊在浮窗中顯示
请求头
| 字段 | 类型 | 描述 |
|---|---|---|
| Authorization | Bearer ${API Key} | 使用Authorization: Bearer ${API Key}进行调用验证,请在 API 密钥页面获取密钥作为API Key。 |
| Content-Type | application/json | 数据类型,取值为 application/json。 |
请求体
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| id | string | 是 | 消息 ID。 |
响应
响应示例
字节流,流式返回
字节流,流式返回
此代碼塊在浮窗中顯示
成功响应
| 字段 | 类型 | 描述 |
|---|---|---|
| Byte[] | 字节流。 |
失败响应
| 字段 | 类型 | 描述 |
|---|---|---|
| code | int | 错误码。 |
| message | string | 错误详情。 |
错误码
| Code | Message |
|---|---|
| 40000 | 参数错误 |
| 40107 | 凭据已过期 |
| 40127 | 开发者鉴权失败 |
| 40325 | 文件类型无效,仅支持‘m4a’,‘mp3’,‘webm’,‘mp4’,‘mpga’,‘wav’,‘mpeg’ |
| 50000 | 系统内部错误 |
| 40113 | 无权访问 Agent |
| 20059 | Agent 已删除 |
| 40371 | 语音播放内容为空 |
| 40379 | 积分不足 |
