> For the complete documentation index, see [llms.txt](https://guides.ia.numerique.gouv.fr/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://guides.ia.numerique.gouv.fr/albert-api/guides/audio-transcription.md).

# Transcription audio

L’endpoint **`POST /v1/audio/transcriptions`** transcrit un fichier audio via un modèle de type **`automatic-speech-recognition`** ([en savoir plus sur les types de modèles](/albert-api/modeles/model-types.md)).

## Transcrire un fichier audio

Le endpoint `/v1/audio/transcriptions` supporte les fichiers `mp3` et `wav` jusqu'à 20 Mb par fichier.

Pour plus d'information sur les paramètres du endpoint, voir la page [API reference - Audio](https://guides.ia.numerique.gouv.fr/albert-api/api-reference/liste-des-endpoint/audio).

**Exemple de requête :**

```bash
curl -sS "https://albert.api.etalab.gouv.fr/v1/audio/transcriptions" \
  -H "Authorization: Bearer $ALBERT_API_KEY" \
  -F "file=@enregistrement.mp3" \
  -F "model=REMPLACER_PAR_MODELE_ASR" \
  -F "language=fr" \
  -F "response_format=json"
```

## Exemples (curl / Python / JavaScript)

{% tabs %}
{% tab title="curl" %}

```bash
curl -sS "https://albert.api.etalab.gouv.fr/v1/audio/transcriptions" \
  -H "Authorization: Bearer $ALBERT_API_KEY" \
  -F "file=@enregistrement.mp3" \
  -F "model=REMPLACER_PAR_MODELE_ASR" \
  -F "language=fr"
```

{% endtab %}

{% tab title="Python" %}

```python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://albert.api.etalab.gouv.fr/v1",
    api_key=os.environ["ALBERT_API_KEY"],
)

with open("enregistrement.mp3", "rb") as f:
    tr = client.audio.transcriptions.create(
        model="REMPLACER_PAR_MODELE_ASR",
        file=f,
        language="fr",
    )
print(tr.text)
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
import fs from "node:fs";
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://albert.api.etalab.gouv.fr/v1",
  apiKey: process.env.ALBERT_API_KEY,
});

const tr = await client.audio.transcriptions.create({
  model: "REMPLACER_PAR_MODELE_ASR",
  file: fs.createReadStream("enregistrement.mp3"),
  language: "fr",
});

console.log(tr.text);
```

{% endtab %}
{% endtabs %}

## Choisir `response_format`

Le paramètre `response_format` permet de choisir le format de la réponse. Ce format dépend de l'usage que vous souhaitez en faire.

| `response_format` | Description                                                                                                                                                     |
| ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `json` (defaut)   | Réponse au format JSON, contient le texte transcrit.                                                                                                            |
| `text`            | Réponse au format TXT, contient uniquement le texte transcrit.                                                                                                  |
| `verbose_json`    | Réponse au format JSON en indiquant le début et la fin de chaque phrase.                                                                                        |
| `srt`             | Réponse au format SRT.                                                                                                                                          |
| `vtt`             | Réponse au format VTT.                                                                                                                                          |
| `diarized_json`   | Réponse au format JSON en indiquant le début et la fin de chaque phrase et les changements de speakers. Ce format utilisé pour les transcriptions des réunions. |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://guides.ia.numerique.gouv.fr/albert-api/guides/audio-transcription.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
