> ## Documentation Index
> Fetch the complete documentation index at: https://veniceai-mintlify-de47a659.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 语音转文本

> 通过 /audio/transcriptions 使用 Venice 语音转文本模型将音频文件转录为文本，可选择响应格式与分段时间戳。

语音转文本可将口语音频转录为文字。向 `/audio/transcriptions` 发送一个音频文件，选择转录模型，并指定所需的响应格式。

在处理对话录音？[用语音转文本生成会议纪要](/guides/media/meeting-notes)从一个音频文件出发，得到能精确引用达成时刻（精确到秒）的决策和行动项，还包括哪些模型会返回分段时间戳，以及如何处理一份从不说明谁在发言的转录文本。

## 基本用法

<CodeGroup>
  ```python Python theme={null}
  import os

  import requests

  with open("meeting.mp3", "rb") as audio:
      response = requests.post(
          "https://api.venice.ai/api/v1/audio/transcriptions",
          headers={"Authorization": f"Bearer {os.environ['VENICE_API_KEY']}"},
          files={"file": audio},
          data={
              "model": "nvidia/parakeet-tdt-0.6b-v3",
              "response_format": "json",
          },
      )

  response.raise_for_status()
  print(response.json()["text"])
  ```

  ```javascript Node.js theme={null}
  import { createReadStream } from "node:fs";
  import FormData from "form-data";

  const form = new FormData();
  form.append("file", createReadStream("meeting.mp3"));
  form.append("model", "nvidia/parakeet-tdt-0.6b-v3");
  form.append("response_format", "json");

  const response = await fetch("https://api.venice.ai/api/v1/audio/transcriptions", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.VENICE_API_KEY}`,
      ...form.getHeaders(),
    },
    body: form,
  });

  if (!response.ok) {
    throw new Error(await response.text());
  }

  const transcript = await response.json();
  console.log(transcript.text);
  ```

  ```bash cURL theme={null}
  curl https://api.venice.ai/api/v1/audio/transcriptions \
    -H "Authorization: Bearer $VENICE_API_KEY" \
    --form file=@meeting.mp3 \
    --form model=nvidia/parakeet-tdt-0.6b-v3 \
    --form response_format=json
  ```
</CodeGroup>

## 支持的输入

支持的音频格式为 `wav`、`wave`、`flac`、`m4a`、`aac`、`mp4`、`mp3`、`ogg`、`oga` 和 `webm`。当文件的 MIME 类型或扩展名在该列表中时即被接受，且上传的字节还必须通过 magic-byte 检查——将文件重命名为受支持的扩展名并不能使其通过。请查阅 [语音转文本模型](/models/speech-to-text) 页面了解当前模型支持情况和价格。

## 响应格式

| 格式     | 适用场景                                              |
| ------ | ------------------------------------------------- |
| `json` | 需要结构化响应时：`text`，以及（如可用）`duration` 和 `timestamps`。 |
| `text` | 需要纯文本、无需解析 JSON 时。                                |

<Note>
  `response_format` 仅接受这两个值。不存在 `srt`、`vtt` 或 `verbose_json` 选项——请求这些值会返回 `400`。要制作字幕，请在 `response_format: json` 下使用 `timestamps: true`，并自行渲染时间数据。
</Note>

## 时间戳

传入 `timestamps=true` 可在转录文本之外获取时间数据。支持情况因模型而异，粒度也不同：

| 模型                            | 粒度        |
| ----------------------------- | --------- |
| `elevenlabs/scribe-v2`        | `word`    |
| `stt-xai-v1`                  | `word`    |
| `openai/whisper-large-v3`     | `segment` |
| `fal-ai/wizper`               | `segment` |
| `nvidia/parakeet-tdt-0.6b-v3` | 无         |

<Warning>
  默认模型 `nvidia/parakeet-tdt-0.6b-v3` 会接受 `timestamps=true` 然后忽略它——您得到的响应只包含 `text`，没有错误也没有警告。如果需要时间信息，请从上表中选择一个模型，并在读取之前检查 `timestamps` 键是否存在。
</Warning>

```bash theme={null}
curl https://api.venice.ai/api/v1/audio/transcriptions \
  -H "Authorization: Bearer $VENICE_API_KEY" \
  --form file=@meeting.mp3 \
  --form model=elevenlabs/scribe-v2 \
  --form timestamps=true \
  --form response_format=json
```

```json theme={null}
{
  "text": "The quick brown fox jumps over the lazy dog.",
  "duration": 4.099,
  "timestamps": {
    "word": [
      { "word": "The", "start": 0.0, "end": 0.14 },
      { "word": "quick", "start": 0.14, "end": 0.42 }
    ]
  }
}
```

分段级模型则返回一个 `segment` 数组，其中每个条目为 `{ "text": "...", "start": 0.0, "end": 3.2 }`。所有时间均以秒为单位。

<Note>
  Venice 的转录模型均不执行说话人分离（speaker diarization），因此任何响应中都没有 `speaker` 字段。转录是单一的文本流——只有当名字被明确说出时才能归属说话人。
</Note>

## 生产环境建议

* 尽量保证音频清晰，避免多人同时说话。
* 如果工作流需要更低延迟或更方便重试，可将过长的录音切分为较小的片段。
* 为每份转录保存原始音频路径、模型 ID 和响应格式，便于审计。

## 相关资源

* [Audio Transcriptions API](/api-reference/endpoint/audio/transcriptions)
* [语音转文本模型](/models/speech-to-text)
* [文本转语音指南](/guides/media/text-to-speech)
