> ## Documentation Index
> Fetch the complete documentation index at: https://gladia-95-docs-live-recommended-parameters.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Automatic language detection

> How to let Gladia detect the spoken language automatically

Gladia can automatically detect the spoken language from audio, either within a candidate set you provide or across all supported languages.

<Note>
  Provide a small list of likely languages when possible. It improves accuracy and reduces latency.
</Note>

## How to use language detection ?

* You **know** the language of the audio ahead of time.
* The audio is **monolingual** (single language throughout).
* You want the **fastest, most accurate** results.

```json theme={"system"}
{
  "language_config": {
    "languages": ["en"],
    "code_switching": false
  }
}
```

## When to use auto-detection

* You process audio in **many different languages** and don't know which one beforehand.
* You want Gladia to pick the language automatically.

## How to use language detection

You can either omit `language_config.languages` (or pass an empty list) to search across all supported languages, or pass a constrained list:

<CodeGroup>
  ```json Detect across all languages theme={"system"}
  {
    "encoding": "wav/pcm",
    "sample_rate": 16000,
    "bit_depth": 16,
    "channels": 1,
    "language_config": {
      "languages": [],
      "code_switching": false
    }
  }
  ```

  ```json Detect within a set of languages theme={"system"}
  {
    "encoding": "wav/pcm",
    "sample_rate": 16000,
    "bit_depth": 16,
    "channels": 1,
    "language_config": {
      "languages": ["en", "de", "fr"],
      "code_switching": false
    }
  }
  ```
</CodeGroup>

The detected `language` is returned on each utterance and can vary over time if you also enable [code switching](/chapters/language/code-switching).

<Warning>
  When `code_switching` is `false` and no language is set, the language is
  detected on the **first utterance** and reused for the rest of the session or
  file. If the beginning of your audio contains silence, music, or a different
  language than the main content, this can lead to incorrect detection for the
  whole transcription.
</Warning>

<Tip>
  Even when using auto-detection, pass a **small list of likely languages** in
  `languages` to constrain the search. This improves both accuracy and
  processing time.
</Tip>

## Tips

* Use [supported languages](/chapters/language/supported-languages) to pick valid ISO 639-1 codes.
* Combine with `messages_config.receive_partial_transcripts` in real time to get immediate feedback.
* For mixed-language conversations, enable [code switching](/chapters/language/code-switching).
