# 文字转语音（TTS）

将文字转换为语音音频。计费方式：按字符数计费（含标点）。
响应为音频二进制流，`Content-Type` 随 `response_format` 变化。

请求体含 `model`（如 `seed-tts-2.0`）、`input`（待合成文本）、`voice`（音色 ID），
可选 `speed`（语速）、`response_format`（输出格式）、`instructions`（语音指令，不计费）。

需要火山原生参数（`ssml`/`explicit_language`/`aigc_watermark` 等）的场景，改用
`POST /v1/audio/speech/unidirectional` 原生透传端点。

## POST /v1/audio/speech

> 文字转语音（TTS）

将文字转换为语音音频。计费方式：按字符数计费（含标点）。
响应为音频二进制流，`Content-Type` 随 `response_format` 变化。

请求体含 `model`（如 `seed-tts-2.0`）、`input`（待合成文本）、`voice`（音色 ID），
可选 `speed`（语速）、`response_format`（输出格式）、`instructions`（语音指令，不计费）。

需要火山原生参数（`ssml`/`explicit_language`/`aigc_watermark` 等）的场景，改用
`POST /v1/audio/speech/unidirectional` 原生透传端点。

### Authentication

`Authorization: Bearer tr-xxx`

### Request Body

Content-Type: `application/json`

- **model** `string` **(required)**  
  语音合成模型 ID，可通过 `GET /v1/models` 过滤 `type: tts` 获取。
- **input** `string` **(required)**  
  需要合成的文本内容，计费按字符数计算
- **voice** `string`  
  发音人（音色）ID，使用豆包语音合成大模型 2.0 音色。完整列表见
- **speed** `number` (default: `1`)  
  语速，`0.25`（1/4 速）– `4.0`（4 倍速），默认 `1`（常速）。内部映射为火山
- **response_format** ``mp3` | `wav` | `pcm` | `opus`` (default: `mp3`)  
  输出音频格式。`pcm` 为无封装原始 PCM（`application/octet-stream`），
- **instructions** `string`  
  语音指令，用自然语言描述期望的语气 / 情感 / 风格（如“用兴奋的语气朗读”）。

### Response

Content-Type: `audio/mpeg` (binary audio stream)

### Error Codes

- `400`: 请求参数错误，或 `response_format` 传了不支持的 `aac`/`flac`
- `401`: 
- `402`: 
- `429`: 
- `502`:
