> For the complete documentation index, see [llms.txt](https://docs.console.zenlayer.com/api-reference/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.console.zenlayer.com/api-reference/cn/compute/aig/audio-edit/openai-audio-transcription.md).

# OpenAI（音频转文字）

## 1. 概述

业界第一大语言模型。根据输入文本生成音频。

**模型列表：**

* `gpt-4o-transcribe`
* `gpt-4o-mini-transcribe`
* `gpt-4o-transcribe-diarize`
* `whisper-1`

## 2. 请求说明

* **请求方法**:`POST`
* **请求地址**:

  > `https://gateway.theturbo.ai/v1/audio/transcriptions`

***

## 3. 请求参数

### 3.1 Header 参数

| 参数名称            | 类型     | 必填 | 说明                                         | 示例值                    |
| --------------- | ------ | -- | ------------------------------------------ | ---------------------- |
| `Authorization` | string | 是  | 身份验证所需的 API\_KEY，格式 `Bearer $YOUR_API_KEY` | `Bearer $YOUR_API_KEY` |

***

∂

### 3.2 Body 参数 (application/json)

| 参数名称                       | 类型     | 必填 | 说明                                                                                                                                                                   | 示例（默认值）             |
| -------------------------- | ------ | -- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- |
| **model**                  | string | 是  | 要使用的模型 ID。详见[概述](#id-1.-gai-shu)列出的可用版本，如 `gpt-4o-transcribe`。                                                                                                       | `gpt-4o-transcribe` |
| **file**                   | string | 是  | 音频文件，支持 flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm                                                                                                           |                     |
| chunking\_strategy         | string | 否  | 控制音频如何被分割成块。                                                                                                                                                         | `auto`              |
| include                    | array  | 否  | 转录响应中包含的附加信息                                                                                                                                                         |                     |
| known\_speaker\_names      | array  | 否  | 可选的说话人名称列表                                                                                                                                                           |                     |
| known\_speaker\_references | array  | 否  | 可选的音频样本列表                                                                                                                                                            |                     |
| language                   | string | 否  | 输入音频的语言 以ISO-639-1格式（例如en）提供输入语言将提高准确性并降低延迟                                                                                                                          | `en`                |
| prompt                     | string | 否  | 用于指导模型风格或延续先前音频片段的可选文本。提示语应与音频语言一致。使用此字段时，不支持gpt-4o-transcribe-diarize.                                                                                              |                     |
| response\_format           | string | 否  | 支持json, text, srt, verbose\_json, vtt, or diarized\_json. gpt-4o-transcribe, gpt-4o-mini-transcribe只支持json. gpt-4o-transcribe-diarize 支持 json, text, diarized\_json  | `text`              |
| stream                     | bool   | 否  | 如果设置为 true，模型响应数据将使用服务器发送事件在生成时以流式传输方式发送给客户端。注意：该型号不支持流媒体播放whisper-1，流媒体播放请求将被忽略。                                                                                    |                     |
| temperature                | bool   | 否  | 采样温度，取值范围为 0 到 1。                                                                                                                                                    | `0.8`               |
| timestamp\_granularities   | array  | 否  | 包含“word”或“segment”元素此转录文本的时间戳粒度response\_format必须设置verbose\_json为使用时间戳粒度。支持以下任一或两个选项：word，或segment。注意：片段时间戳不会增加额外延迟，但生成单词时间戳会产生额外延迟。此选项不适用于gpt-4o-transcribe-diarize | `word`              |

***

## 4. 请求示例

```http
curl --request POST 'https://gateway.theturbo.ai/v1/audio/transcriptions' \
--header 'Authorization: Bearer sk-***' \
--form 'file=@"/Users/xiaobo.yang/Documents/study/speech_test/2.mp3";filename="2.mp3"; headers="Content-Type: audio/mpeg"' \
--form 'timestamp_granularities[]=word' \
--form 'model=gpt-4o-mini-transcribe' \
--form 'response_format=verbose_json' \
--form 'language=zh'
```

## 5. 响应示例

```json
{
  "task": "transcribe",
  "language": "zh",
  "duration": 3.3066875,
  "text": "Hello, where are you?",
  "words": [
    {
      "start": 0,
      "end": 0.56,
      "word": "Hello,",
      "probability": 0.7631836
    },
    {
      "start": 0.72,
      "end": 1.26,
      "word": " where",
      "probability": 0.66064453
    },
    {
      "start": 1.26,
      "end": 1.68,
      "word": " are",
      "probability": 0.9970703
    },
    {
      "start": 1.68,
      "end": 2.04,
      "word": " you?",
      "probability": 0.99316406
    }
  ],
  "segments": [
    {
      "id": 1,
      "seek": 330,
      "start": 0,
      "end": 2.04,
      "text": "Hello, where are you?",
      "tokens": [
        50365,
        15947,
        11,
        689,
        366,
        291,
        30,
        50530
      ],
      "temperature": 0,
      "avg_logprob": -0.2973090277777778,
      "compression_ratio": 0.7777777777777778,
      "no_speech_prob": 0.1317138671875,
      "words": [
        {
          "start": 0,
          "end": 0.56,
          "word": "Hello,",
          "probability": 0.7631836
        },
        {
          "start": 0.72,
          "end": 1.26,
          "word": " where",
          "probability": 0.66064453
        },
        {
          "start": 1.26,
          "end": 1.68,
          "word": " are",
          "probability": 0.9970703
        },
        {
          "start": 1.68,
          "end": 2.04,
          "word": " you?",
          "probability": 0.99316406
        }
      ]
    }
  ]
}
```
