> ## Documentation Index
> Fetch the complete documentation index at: https://api.xcompute.us/llms.txt
> Use this file to discover all available pages before exploring further.

# 文字转语音

* 文字转语音接口
* 输出高质量音频格式
* 最大输入文本 4096 个字符

## 支持模型

* `gpt-4o-mini-tts`

## 参数字段

<ParamField body="model" type="string" default="gpt-4o-mini-tts" required>
  固定填写 `gpt-4o-mini-tts`。
</ParamField>

<ParamField body="input" type="string" required>
  要转换成语音的文本内容。
</ParamField>

<ParamField body="voice" type="string" required>
  音色名称。

  可选值：`alloy`、`echo`、`fable`、`onyx`、`nova`、`shimmer`。
</ParamField>

<ParamField body="response_format" type="string" default="wav">
  输出格式。

  可选值：`wav`、`opus`、`aac`、`flac`、`pcm`。
</ParamField>

<ParamField body="speed" type="number" default="1.0">
  播放速度，范围 `0.25 ~ 4.0`。
</ParamField>

<RequestExample>
  ```bash cURL theme={null} theme={null}
  curl --request POST \
    --url https://xcompute.us/v1/audio/speech \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "gpt-4o-mini-tts",
      "input": "今天天气真好,适合出去散步。",
      "voice": "alloy",
      "response_format": "opus",
      "speed": 1.0
    }' \
    --output speech.opus
  ```
</RequestExample>

<Note>
  成功时返回二进制音频数据流，可以直接保存为音频文件或播放。
</Note>
