# 音频

### 创建转录

```
POST https://api.openai.com/v1/audio/transcriptions
```

将音频转录成输入语言。

#### 请求体

* file 字符串 必填项 要转录的音频文件，格式为：mp3、mp4、mpeg、mpga、m4a、wav或webm。
* model 字符串 必填项 要使用的模型ID。目前只有whisper-1可用。
* prompt 字符串 可选项 可选的文本，用于指导模型的风格或继续前一个音频片段。提示应与音频语言匹配。
* response\_format 字符串 可选项 默认为json 转录输出的格式，可选择以下选项之一：json、text、srt、verbose\_json或vtt。
* temperature 数字 可选项 默认为0 采样温度，介于0和1之间。较高的值（如0.8）将使输出更随机，而较低的值（如0.2）将使其更具有针对性和确定性。如果设置为0，模型将使用对数概率自动增加温度，直到达到一定的阈值。
* language 字符串 可选项 输入音频的语言。以ISO-639-1格式提供输入语言将提高准确性和延迟。

#### 请求示例

{% tabs %}
{% tab title="curl" %}
{% code lineNumbers="true" %}

```sh
curl https://api.openai.com/v1/audio/transcriptions \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: multipart/form-data" \
  -F file="@/path/to/file/audio.mp3" \
  -F model="whisper-1"
```

{% endcode %}
{% endtab %}

{% tab title="python" %}
{% code lineNumbers="true" %}

```python
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
audio_file = open("audio.mp3", "rb")
transcript = openai.Audio.transcribe("whisper-1", audio_file)

```

{% endcode %}
{% endtab %}

{% tab title="node.js" %}
{% code lineNumbers="true" %}

```javascript
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
  apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const resp = await openai.createTranscription(
  fs.createReadStream("audio.mp3"),
  "whisper-1"
);

```

{% endcode %}
{% endtab %}
{% endtabs %}

{% code title="请求参数" lineNumbers="true" %}

```json
{
  "file": "audio.mp3",
  "model": "whisper-1"
}

```

{% endcode %}

{% code title="返回值" lineNumbers="true" %}

```json
{
  "text": "Imagine the wildest idea that you've ever had, and you're curious about how it might scale to something that's a 100, a 1,000 times bigger. This is a place where you can get to do that."
}

```

{% endcode %}

### 创建翻译

```
POST https://api.openai.com/v1/audio/translations
```

将音频翻译成英语。

#### 请求体

* file 字符串 必填 需要翻译的音频文件，格式可以是以下之一：mp3，mp4，mpeg，mpga，m4a，wav或webm。
* model 字符串 必填 要使用的模型的ID。目前只有whisper-1可用。
* prompt 字符串 可选 可用于指导模型的风格或继续前一个音频片段的可选文本。提示应该是英文。
* response\_format 字符串 可选 默认为json 转录输出的格式，可以是以下选项之一：json，text，srt，verbose\_json或vtt。
* temperature 数字 可选 默认为0 采样温度，介于0和1之间。较高的值（如0.8）将使输出更加随机，而较低的值（如0.2）将使其更加集中和确定性。如果设置为0，模型将使用对数概率自动增加温度，直到达到某些阈值。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.luojixiangliang.com/reference/openai-api-can-kao-wen-dang/yin-pin.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
