# Transcription

> Whisper large-v3 transcription with speaker diarization

Source: https://platform.snapany.com/docs/transcription

Asynchronous audio/video transcription powered by **Whisper large-v3**, with optional speaker diarization.

**Billing**: 4 credits per minute (rounded up), reserved at submission, automatically refunded if the job fails.

Endpoints: [`POST /transcriptions`](https://platform.snapany.com/docs/api#POST/transcriptions) [`GET /transcriptions/{id}`](https://platform.snapany.com/docs/api#GET/transcriptions/%7Bid%7D)

## Submit a job

Pass a publicly accessible URL (recommended — e.g. a media URL from Extract Post):

```bash
curl -X POST https://api.snapany.com/openapi/v1/transcriptions \
  -H "Authorization: Bearer sk_snapany_xxx" \
  -H "Content-Type: application/json" \
  -d '{"fileUrl": "https://example.com/audio.mp3", "speakerLabels": true, "maxSpeakers": 2}'
```

Or upload a local file (max 512MB, max 6 hours):

```bash
curl -X POST https://api.snapany.com/openapi/v1/transcriptions \
  -H "Authorization: Bearer sk_snapany_xxx" \
  -F "file=@meeting.mp3" -F "speakerLabels=true"
```

Response: `{ "id": "...", "status": "processing", "duration": 605.3 }`

## Poll for the result

```bash
curl https://api.snapany.com/openapi/v1/transcriptions/{id} \
  -H "Authorization: Bearer sk_snapany_xxx"
```

Poll every **3–5 seconds** (polling is free). A polling loop:

```python
import time
import requests

headers = {"Authorization": f"Bearer {API_KEY}"}
url = f"https://api.snapany.com/openapi/v1/transcriptions/{job_id}"

while True:
    job = requests.get(url, headers=headers).json()
    if job["status"] == "completed":
        print(job["result"]["text"])
        break
    if job["status"] == "failed":
        # reserved credits are refunded automatically
        print("failed:", job["error"])
        break
    time.sleep(5)
```

When `status` is `completed`, `result` contains the Whisper verbose_json output: full `text`, detected `language`, and `segments` with start/end timestamps — each segment carries a `speaker` label when diarization is enabled.
