一、HTTP 请求 Header
Content-Type: application/json;charset=UTF-8
X-Task-Id: task_id_value
X-Rquest-Id: request_id
X-Sdk-App-Id: SdkAppId
X-User-Id:UserId
X-Room-Id:RoomId
X-Room-Id-Type: "0"
Authorization: Bearer "API-KEY"
二、请求体示例
{
"Text": "你好,世界!这是流式 TTS API 的测试。",
"Format": "wav",
"SampleRate": 16000,
"Channel": 1
}
三、HTTP 请求 Header
| 字段 | 描述 |
| Content-Type | application/json |
| charset | UTF-8 |
| X-Task-Id | 对话任务的 Id |
| X-Request-Id | 此次请求的 Id, 重试会携带相同的 RequestId |
| X-Sdk-App-Id | SDK的AppId |
| X-User-Id | 用户Id |
| X-Room-Id | Romm Id |
| X-Room-Id-Type | Romm Id的类型,0 – 数字房间号,1 – 表示字符串房间号 |
| Authorization | 鉴权,格式为Bearer "API-KEY" |
四、请求体
| 参数名称 | 必填 | 类型 | 描述 |
| Text | 是 | String | 语音文本 |
| Format | 否 | String | 期望输出的音频格式,如mp3, ogg_opus,pcm,wav,默认为 wav,一期只支持pcm和wav |
| SampleRate | 否 | Integer | 音频采样率,默认为16000(16k),推荐值为16000 |
| Channel | 否 | Integer | 音频通道,取值:1 或 2 默认 1 |
五、响应
需要根据 Content-Type 的值来确定合成是否成功。
·如果成功,正常返回为二进制语音,不同的音频格式的 Content-Type 如下,需要在 HTTP 响应的 Header 设置 Transfer-Encoding: chunked。
注意:Response Header 中必须包含 Content-Type 和 Transfer-Encoding,我们服务会强制检查。
注意:比如:
注意:{
注意:Transfer-Encoding: chunked;
注意:Content-Type: audio/L16
注意:}
| 音频格式 | Content-Type |
| mp3 | audio/mpeg |
| ogg_opus | audio/ogg |
| pcm | audio/L16 |
| wav | audio/wav |
·如果失败,则会返回 json 结果,具体 header 信息为:Content-type: application/json。响应为:
{
"error": {
"code": "ERROR_CODE",
"message": "A description of the error"
}
}