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

# Reconnaissance vocale (Speech-to-Text)

> Utilisez les modèles Whisper pour convertir des fichiers audio en texte, avec prise en charge de la transcription et de la traduction

## Introduction

L'API de reconnaissance vocale (STT) basée sur les modèles Whisper d'OpenAI peut convertir des fichiers audio en texte. Elle prend en charge divers cas d'usage :

* Transcrire des fichiers audio en texte
* Traduire de l'audio multilingue en anglais
* Prendre en charge plusieurs formats audio en entrée
* Proposer plusieurs options de format de sortie

**Liste des modèles disponibles :**

* **whisper-large-v3** — Dernier grand modèle Whisper, prend en charge de nombreuses langues. Pour la reconnaissance du chinois, utilisez-le avec des prompts appropriés et une température basse
* **whisper-1** — Modèle Whisper d'origine, stable et fiable, prend en charge plusieurs langues
* **distil-whisper-large-v3-en** — Modèle distillé, plus rapide mais légèrement moins précis ; recommandé avec une faible température

<Tip>
  **Recommandations de performance :**

  * Pour l'audio en chinois, utilisez le modèle `whisper-large-v3` avec des prompts appropriés et des températures plus faibles (par exemple 0,2) afin de réduire les hallucinations
  * Pour l'audio anglais ou un traitement plus rapide, utilisez le modèle `distil-whisper-large-v3-en`
  * Formats audio pris en charge : mp3, mp4, mpeg, mpga, m4a, wav, webm
  * Limite de taille de fichier : 25 Mo maximum
</Tip>

## Utilisation du modèle

### Transcription vocale

Utilisez l'endpoint `/v1/audio/transcriptions` via la méthode `client.audio.transcriptions.create()` pour transcrire l'audio en texte dans la langue d'origine.

### Traduction vocale

Utilisez l'endpoint `/v1/audio/translations` via la méthode `client.audio.translations.create()` pour traduire l'audio en texte anglais.

### Paramètres de requête

#### Paramètres de transcription

<ParamField body="file" type="file" required>
  Objet fichier audio à transcrire. Formats pris en charge : mp3, mp4, mpeg, mpga, m4a, wav, webm, 25 Mo maximum
</ParamField>

<ParamField body="model" type="string" required>
  ID de modèle à utiliser. Options : `whisper-large-v3`, `whisper-1`, `distil-whisper-large-v3-en`
</ParamField>

<ParamField body="language" type="string">
  Langue de l'audio d'entrée au format ISO-639-1 (par exemple, 'en', 'zh'). Spécifier la langue peut améliorer la précision et la latence
</ParamField>

<ParamField body="prompt" type="string">
  Prompt textuel facultatif pour guider le style du modèle ou poursuivre un segment audio précédent. Le prompt doit correspondre à la langue de l'audio
</ParamField>

<ParamField body="response_format" type="string">
  Format de sortie de la transcription. Options : `json` (par défaut), `text`, `srt`, `verbose_json`, `vtt`
</ParamField>

<ParamField body="temperature" type="number">
  Température d'échantillonnage entre 0 et 1. Des valeurs plus élevées rendent la sortie plus aléatoire, des valeurs plus basses la rendent plus déterministe. Valeur par défaut : 0
</ParamField>

<ParamField body="timestamp_granularities[]" type="array">
  Granularités des horodatages. Options : `word`, `segment`. Disponible uniquement lorsque response\_format vaut verbose\_json
</ParamField>

#### Paramètres de traduction

<ParamField body="file" type="file" required>
  Objet fichier audio à traduire. Mêmes formats que pour la transcription
</ParamField>

<ParamField body="model" type="string" required>
  ID de modèle à utiliser, identique aux paramètres de transcription
</ParamField>

<ParamField body="prompt" type="string">
  Prompt textuel facultatif en anglais pour guider le style de traduction
</ParamField>

<ParamField body="response_format" type="string">
  Format de sortie de la traduction, identique aux paramètres de transcription
</ParamField>

<ParamField body="temperature" type="number">
  Température d'échantillonnage, identique aux paramètres de transcription
</ParamField>

## Exemples d'utilisation

<CodeGroup>
  ```shell Curl Transcription theme={null}
  curl https://aihubmix.com/v1/audio/transcriptions \
    -H "Authorization: Bearer $AIHUBMIX_API_KEY" \
    -H "Content-Type: multipart/form-data" \
    -F file="@/path/to/file/audio.mp3" \
    -F model="whisper-large-v3" \
    -F response_format="text" \
    -F temperature="0.2"
  ```

  ```shell Curl Translation theme={null}
  curl https://aihubmix.com/v1/audio/translations \
    -H "Authorization: Bearer $AIHUBMIX_API_KEY" \
    -H "Content-Type: multipart/form-data" \
    -F file="@/path/to/file/audio.mp3" \
    -F model="whisper-large-v3" \
    -F prompt="autocorrect, clean up the stammer, and translate to english" \
    -F response_format="text" \
    -F temperature="0.2"
  ```

  ```py Speech Transcription theme={null}
  from openai import OpenAI
  import os

  client = OpenAI(
    api_key="sk-***", # Replace with your AiHubMix API key
    base_url="https://aihubmix.com/v1"
  )

  # Open audio file
  audio_file = open("path/to/audio.mp3", "rb")

  # Transcribe audio
  transcript = client.audio.transcriptions.create(
    model="whisper-large-v3",
    file=audio_file,
    language="en",  # Specify English for better accuracy
    prompt="Please transcribe accurately with proper punctuation and grammar",
    response_format="text",
    temperature=0.2  # Lower randomness to reduce hallucinations
  )

  print(transcript)
  ```

  ```py Speech Translation theme={null}
  from openai import OpenAI
  import os

  client = OpenAI(
    api_key="sk-***", # Replace with your AiHubMix API key
    base_url="https://aihubmix.com/v1"
  )

  # Open audio file
  audio_file = open("path/to/audio.m4a", "rb")

  # Translate audio to English
  translation = client.audio.translations.create(
    model="whisper-large-v3",
    file=audio_file,
    prompt="autocorrect, clean up the stammer, and translate to english",
    response_format="text",
    temperature=0.2
  )

  print(translation)
  ```

  ```py Verbose Output Format theme={null}
  from openai import OpenAI
  import os

  client = OpenAI(
    api_key="sk-***", # Replace with your AiHubMix API key
    base_url="https://aihubmix.com/v1"
  )

  audio_file = open("path/to/audio.wav", "rb")

  # Get detailed transcription results with timestamps
  transcript = client.audio.transcriptions.create(
    model="whisper-large-v3",
    file=audio_file,
    response_format="verbose_json",
    timestamp_granularities=["word"],
    temperature=0.2
  )

  # Output results with word-level timestamps
  print(f"Text: {transcript.text}")
  print(f"Language: {transcript.language}")
  for word in transcript.words:
      print(f"'{word.word}' at {word.start}s - {word.end}s")
  ```

  ```py SRT Subtitle Format theme={null}
  from openai import OpenAI
  import os

  client = OpenAI(
    api_key="sk-***", # Replace with your AiHubMix API key
    base_url="https://aihubmix.com/v1"
  )

  audio_file = open("path/to/video_audio.mp4", "rb")

  # Generate SRT subtitle file
  srt_transcript = client.audio.transcriptions.create(
    model="whisper-large-v3",
    file=audio_file,
    response_format="srt",
    language="en",
    temperature=0.2
  )

  # Save as .srt file
  with open("subtitles.srt", "w", encoding="utf-8") as f:
      f.write(srt_transcript)

  print("SRT subtitle file generated")
  ```
</CodeGroup>

## Formats de réponse

### Format JSON (par défaut)

```json theme={null}
{
  "text": "This is the transcribed text content"
}
```

### Format JSON détaillé (verbose\_json)

```json theme={null}
{
  "task": "transcribe",
  "language": "english",
  "duration": 8.470000267028809,
  "text": "This is the transcribed text content",
  "segments": [
    {
      "id": 0,
      "seek": 0,
      "start": 0.0,
      "end": 8.470000267028809,
      "text": " This is the transcribed text content",
      "tokens": [50364, 50365, 50365, 50365],
      "temperature": 0.2,
      "avg_logprob": -0.9929364013671875,
      "compression_ratio": 0.8888888888888888,
      "no_speech_prob": 0.0963134765625
    }
  ]
}
```

### Format texte

```
This is the transcribed text content
```

### Format SRT

```srt theme={null}
1
00:00:00,000 --> 00:00:08,470
This is the transcribed text content
```

### Format VTT

```vtt theme={null}
WEBVTT

00:00:00.000 --> 00:00:08.470
This is the transcribed text content
```

## Bonnes pratiques

1. **Traitement de l'audio en chinois** : utilisez le modèle `whisper-large-v3`, définissez `language="zh"`, `temperature=0.2` et fournissez des prompts chinois appropriés
2. **Traitement de l'audio en anglais** : utilisez `distil-whisper-large-v3-en` pour un traitement plus rapide
3. **Gestion du bruit** : utilisez des prompts pour indiquer au modèle d'ignorer le bruit de fond ou de nettoyer les bégaiements
4. **Traitement de l'audio long** : l'API segmente automatiquement les longs fichiers audio ; il est recommandé de prétraiter la qualité audio pour de meilleurs résultats
5. **Besoins en horodatage** : utilisez le format `verbose_json` et `timestamp_granularities` lorsque des horodatages précis sont nécessaires
6. **Création de sous-titres** : utilisez directement la sortie au format `srt` ou `vtt` sans traitement supplémentaire

***

Dernière mise à jour : 2026-06-01
