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

# Fish Audio 语音合成

<Note>
  为了获得最佳效果，建议在使用此 API 之前，先使用[音频复刻](/docs/models/reference-fish-audio-voice-cloning)上传参考音频。这将提高语音质量并降低延迟。
</Note>

Fish Audio 将文本转换为语音。

支持的音频格式：

* WAV / PCM
  * 采样率：8kHz, 16kHz, 24kHz, 32kHz, 44.1kHz
  * 默认采样率：44.1kHz
  * 16-bit，单声道

* MP3
  * 采样率：32kHz, 44.1kHz
  * 默认采样率：44.1kHz
  * 单声道
  * 比特率：64kbps, 128kbps (默认), 192kbps

* Opus
  * 采样率：48kHz
  * 默认采样率：48kHz
  * 单声道
  * 比特率：-1000 (自动), 24kbps, 32kbps (默认), 48kbps, 64kbps

## 请求头

<ParamField header="Content-Type" type="string" required={true}>
  枚举值: `application/json`
</ParamField>

<ParamField header="Authorization" type="string" required={true}>
  Bearer 身份验证格式: Bearer \{\{API 密钥}}。
</ParamField>

## 请求体

<ParamField body="text" type="string" required={true}>
  要转换为语音的文本。
</ParamField>

<ParamField body="temperature" type="number" default={0.9}>
  控制语音生成的随机性。较高的值（例如 1.0）使输出更随机，较低的值（例如 0.1）使其更确定。我们建议 `s1` 模型使用 `0.9`。

  必需范围：`0 <= x <= 1`
</ParamField>

<ParamField body="top_p" type="number" default={0.9}>
  通过核采样控制多样性。较低的值（例如 0.1）使输出更集中，较高的值（例如 1.0）允许更多样性。我们建议 `s1` 模型使用 `0.9`。

  必需范围：`0 <= x <= 1`
</ParamField>

<ParamField body="references" type="ReferenceAudio · object[] | null">
  用于语音的参考音频，这需要 MessagePack 序列化，这将覆盖 reference\_voices 和 reference\_texts。

  <Expandable title="properties">
    <ParamField body="audio" type="file" required={true}>
      参考音频文件。
    </ParamField>

    <ParamField body="text" type="string" required={true}>
      与音频对应的参考文本。
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="reference_id" type="string | null">
  用于语音的参考模型 ID。
</ParamField>

<ParamField body="prosody" type="ProsodyControl · object">
  用于语音的韵律控制。

  <Expandable title="properties">
    <ParamField body="speed" type="number" default={1}>
      语音速度控制。
    </ParamField>

    <ParamField body="volume" type="number" default={0}>
      语音音量控制。
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="chunk_length" type="integer" default={200}>
  用于语音的分块长度。

  必需范围：`100 <= x <= 300`
</ParamField>

<ParamField body="normalize" type="boolean" default={true}>
  是否规范化语音，这将降低延迟，但可能会降低对数字和日期的处理性能。
</ParamField>

<ParamField body="format" type="enum<string>" default="mp3">
  用于语音的格式。

  可选值：`wav`, `pcm`, `mp3`, `opus`
</ParamField>

<ParamField body="sample_rate" type="integer | null">
  用于语音的采样率。
</ParamField>

<ParamField body="mp3_bitrate" type="enum<integer>" default={128}>
  用于语音的 MP3 比特率。

  可选值：`64`, `128`, `192`
</ParamField>

<ParamField body="opus_bitrate" type="enum<integer>" default={32}>
  用于语音的 Opus 比特率。

  可选值：`-1000`, `24`, `32`, `48`, `64`
</ParamField>

<ParamField body="latency" type="enum<string>" default="normal">
  用于语音的延迟设置，balanced 将降低延迟但可能导致性能下降。

  可选值：`normal`, `balanced`
</ParamField>

## 响应信息

API 将直接返回由 `format` 参数指定格式的音频流（默认：mp3）。
