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

# Speech-to-Text (STT)

> Transcribe audio files to text with confidence scoring

<Note>
  All requests require an API key in the Authorization header.
</Note>

## Base URL

```
http://stt.sawt.sa/
```

## Authentication

<ParamField header="Authorization" required>
  Bearer your-api-key-here
</ParamField>

## POST /transcribe

Transcribe audio files to text with confidence scoring.

### Request Headers

<ParamField header="Authorization" required>
  Bearer YOUR\_API\_KEY
</ParamField>

<ParamField header="Content-Type" required>
  multipart/form-data
</ParamField>

### Request Parameters

<ParamField body="file" type="file" required>
  Audio file (supported formats: WAV, MP3, M4A, etc.)
</ParamField>

<ParamField body="job_id" type="string">
  Custom job identifier for tracking (optional)
</ParamField>

### Audio Requirements

* Minimum duration: 10 milliseconds
* Automatically resampled to 16kHz
* Supports common audio formats (WAV, MP3, M4A, etc.)

## Response

<ResponseField name="transcription" type="string" required>
  The transcribed text from the audio file
</ResponseField>

<ResponseField name="confidence" type="number" required>
  Confidence score of the transcription (0-1)
</ResponseField>

<Accordion title="Example Response">
  ```json theme={null}
  {
    "transcription": "النص المكتوب",
    "confidence": 0.95
  }
  ```
</Accordion>

## Error Codes

| Status Code | Description                            |
| ----------- | -------------------------------------- |
| 400         | Invalid audio file or processing error |
| 401         | Invalid or missing API key             |
| 500         | Internal server error                  |

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "http://stt.sawt.sa/transcribe" \
    -H "Authorization: Bearer your-api-key" \
    -F "file=@audio.wav"
  ```

  ```javascript Node.js theme={null}
  const FormData = require('form-data');
  const fs = require('fs');
  const axios = require('axios');

  const transcribeAudio = async () => {
    try {
      const form = new FormData();
      form.append('file', fs.createReadStream('./audio.wav'));
      form.append('job_id', 'optional-job-id');

      const response = await axios.post(
        'http://stt.sawt.sa/transcribe',
        form,
        {
          headers: {
            'Authorization': 'Bearer your-api-key',
            ...form.getHeaders()
          }
        }
      );

      console.log(response.data);
      return response.data;
    } catch (error) {
      console.error(error);
    }
  };

  transcribeAudio();
  ```

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

  def transcribe_audio():
      url = "http://stt.sawt.sa/transcribe"
      
      headers = {
          "Authorization": "Bearer your-api-key"
      }
      
      files = {
          "file": open("audio.wav", "rb")
      }
      
      data = {
          "job_id": "optional-job-id"
      }
      
      try:
          response = requests.post(url, headers=headers, files=files, data=data)
          response.raise_for_status()
          return response.json()
      except requests.exceptions.RequestException as e:
          print(f"Error: {e}")
          return None

  result = transcribe_audio()
  print(result)
  ```
</RequestExample>
