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

# 音频转录

> <ul><li>将音频转换为文本</li></ul>

<RequestExample>
  ```bash cURL theme={null} theme={null}
  curl --request POST \
    --url 'https://api.elkapi.com/v1/audio/transcriptions' \
    --header 'Authorization: Bearer <token>' \
    --form 'file=@audio.mp3' \
    --form 'model=whisper-1' \
    --form 'language=language' \
    --form 'prompt=一只小猫在阳光下的花园里奔跑，电影感，高细节' \
    --form 'response_format=json' \
    --form 'temperature=1' \
    --form 'timestamp_granularities=word'
  ```

  ```python Python theme={null} theme={null}
  import requests

  url = "https://api.elkapi.com/v1/audio/transcriptions"
  headers = {
      "Authorization": "Bearer <token>"
  }
  files = {
      "file": open("audio.mp3", "rb"),
  }
  data = {
      "model": "whisper-1",
      "language": "language",
      "prompt": "一只小猫在阳光下的花园里奔跑，电影感，高细节",
      "response_format": "json",
      "temperature": "1",
      "timestamp_granularities": "word",
  }

  response = requests.request("POST", url, headers=headers, data=data, files=files)
  print(response.text)
  ```

  ```javascript JavaScript theme={null} theme={null}
  const url = "https://api.elkapi.com/v1/audio/transcriptions";

  const headers = {
    "Authorization": "Bearer <token>"
  };
  const form = new FormData();
  form.append("file", fileInput.files[0]);
  form.append("model", "whisper-1");
  form.append("language", "language");
  form.append("prompt", "一只小猫在阳光下的花园里奔跑，电影感，高细节");
  form.append("response_format", "json");
  form.append("temperature", "1");
  form.append("timestamp_granularities", "word");

  const response = await fetch(url, {
    method: "POST",
    headers,
    body: form
  });

  console.log(await response.text());
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null} theme={null}
  {
    "text": "你好，请介绍一下你自己"
  }
  ```
</ResponseExample>

## Authorizations

<ParamField header="Authorization" type="string" required>
  所有接口均需要使用 Bearer Token 进行认证。

  在请求头中添加：

  ```
  Authorization: Bearer YOUR_API_KEY
  ```
</ParamField>

## Body

<ParamField body="file" type="file" required>
  音频文件
</ParamField>

<ParamField body="model" type="string" required default="whisper-1">
  示例：`whisper-1`
</ParamField>

<ParamField body="language" type="string">
  ISO-639-1 语言代码
</ParamField>

<ParamField body="prompt" type="string" />

<ParamField body="response_format" type="string" default="json">
  可选值：`json`、`text`、`srt`、`verbose_json`、`vtt`
</ParamField>

<ParamField body="temperature" type="number" />

<ParamField body="timestamp_granularities" type="array<string>" />

## Response

<ResponseField name="text" type="string" />
