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

# Language Detection

> Identify languages from text or audio

Sunbird AI can automatically detect the language of a given text or audio file. This is useful for routing content to the correct translation or transcription pipeline.

## Text Language Identification

Use the `/tasks/language_id` endpoint to identify the language of a text string.

### Supported Languages

* Acholi (`ach`)
* Ateso (`teo`)
* English (`eng`)
* Luganda (`lug`)
* Lugbara (`lgg`)
* Runyankole (`nyn`)

### Example Request

<CodeGroup>
  ```python Python theme={null}
  import os
  import requests
  from dotenv import load_dotenv

  load_dotenv()

  url = "https://api.sunbird.ai/tasks/language_id"
  access_token = os.getenv("AUTH_TOKEN")

  headers = {
      "accept": "application/json",
      "Authorization": f"Bearer {access_token}",
      "Content-Type": "application/json",
  }

  payload = {"text": "Oli otya? Webale nnyo ku kujja wano."}

  response = requests.post(url, headers=headers, json=payload)
  result = response.json()
  print(f"Detected language: {result}")
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.sunbird.ai/tasks/language_id', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_TOKEN>',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ text: 'Oli otya? Webale nnyo ku kujja wano.' })
  });
  console.log(await response.json());
  ```
</CodeGroup>

### Response

```json theme={null}
{
  "output": {
    "language": "lug",
    "confidence": 0.98
  }
}
```

## Audio Language Detection

Use the `/tasks/auto_detect_audio_language` endpoint to identify the language spoken in an audio file.

### Example Request

<CodeGroup>
  ```python Python theme={null}
  import os
  import requests
  from dotenv import load_dotenv

  load_dotenv()

  url = "https://api.sunbird.ai/tasks/auto_detect_audio_language"
  access_token = os.getenv("AUTH_TOKEN")

  files = {"audio": open("recording.mp3", "rb")}
  headers = {"Authorization": f"Bearer {access_token}"}

  response = requests.post(url, files=files, headers=headers)
  print(response.json())
  ```
</CodeGroup>

### Response

```json theme={null}
{
  "output": {
    "language": "ach",
    "confidence": 0.85
  }
}
```
