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

# HTTP examples

> Code samples in curl, Python, and Node.js for basic transcription, word timestamps, and diarization.

These examples use the Deepgram Nova model; see the [Speech-to-Text models](https://slng.mintlify.site/models/stt.md) for other models and endpoints.

## Placeholders

The snippets below use these placeholders. Replace them before running the code.

| Placeholder | Replace with |
| - | - |
| `SLNG_API_KEY` | An SLNG key from [app.slng.ai/api-keys](https://app.slng.ai/api-keys) |

## Basic File Transcription

Upload an audio file (MP3, WAV, FLAC, OGG, M4A, or WebM) and get back the transcribed text. Here is a sample file you can use:

Micro Machines sample

Download this file to try the example below.

[Download](https://slng.mintlify.site/audio/micro-machines.wav)

<audio controls preload="metadata" aria-label="Micro Machines sample" src="https://slng.mintlify.site/audio/micro-machines.wav">Your browser does not support the audio element.</audio>

```bash cURL theme={null}
curl https://api.slng.ai/v1/stt/slng/deepgram/nova:3-en \
  -H "Authorization: Bearer SLNG_API_KEY" \
  -F "audio=@micro-machines.wav"
```

```javascript JavaScript theme={null}
const formData = new FormData();
formData.append("audio", audioFile); // File from <input type="file">

const response = await fetch(
  "https://api.slng.ai/v1/stt/slng/deepgram/nova:3-en",
  {
    method: "POST",
    headers: {
      Authorization: "Bearer SLNG_API_KEY",
    },
    body: formData,
  },
);

const result = await response.json();
console.log("Transcription:", result.results.channels[0].alternatives[0].transcript);
```

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

url = "https://api.slng.ai/v1/stt/slng/deepgram/nova:3-en"
headers = {"Authorization": "Bearer SLNG_API_KEY"}

with open("micro-machines.wav", "rb") as audio_file:
    response = requests.post(url, headers=headers, files={"audio": audio_file})

result = response.json()
print("Transcription:", result["results"]["channels"][0]["alternatives"][0]["transcript"])
```

You should get a response like this:

```json theme={null}
{
  "metadata": {
    "request_id": "e5fed572-6eac-4b70-81f3-21ba1641dd12",
    "duration": 29.888374,
    "channels": 1,
    "model_info": {
      "1abfe86b-e047-4eed-858a-35e5625b41ee": {
        "name": "2-general-nova",
        "version": "2024-01-06.5664",
        "arch": "nova-2"
      }
    }
  },
  "results": {
    "channels": [
      {
        "alternatives": [
          {
            "transcript": "is the micro machine man presenting the most midget miniature motocator of micro machine...",
            "confidence": 0.9823751,
            "words": [
              { "word": "is", "start": 0.16, "end": 0.32, "confidence": 0.998 },
              { "word": "the", "start": 0.32, "end": 0.40, "confidence": 0.613 },
              { "word": "micro", "start": 0.40, "end": 0.64, "confidence": 0.727 },
              ...
            ]
          }
        ]
      }
    ]
  }
}
```

***

## Going further

You can pass additional form fields to customize the transcription:

* **Language**: If you know the language, pass `language=en` (or `es`, `fr`, etc.). Not all models auto-detect, so setting this explicitly can improve accuracy.
* **Diarization**: Pass `diarize=true` to identify different speakers in a multi-speaker recording. The response will include a `speaker` field on each word. PLease check the models documentation for specific diarization config.
* **Punctuation**: Pass `punctuate=true` to add punctuation to the transcript automatically.

For the full parameter list per model, see the [Speech-to-Text API reference](https://slng.mintlify.site/api-reference/stt/deepgram-nova-3/nova-3-ws.md).

***

## Next Steps

> **[Live STT demo](https://slng-stt-demo.onrender.com/)**
>
> Try real-time speech recognition in your browser, no setup needed

> **[STT WebSocket examples](https://slng.mintlify.site/examples/stt-websocket.md)**
>
> Real-time transcription as users speak

> **[Speech-to-Text models](https://slng.mintlify.site/models/stt.md)**
>
> Browse all STT models and endpoints

> **[STT API reference](https://slng.mintlify.site/api-reference/stt/deepgram-nova-3/nova-3-ws.md)**
>
> Endpoint-specific parameters


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.