# Migrate from Azure AI Speech to Gladia

Last updated: 2026-11-12

Azure AI Speech is used through its Speech SDK: a recognizer pulls audio from a stream and raises `recognizing` and `recognized` events. Gladia's SDKs work the same way with an open protocol underneath: push the audio, get partial and final `transcript` messages. Batch transcription maps to a pre-recorded job. The Gladia SDKs (`gladiaio-sdk` for Python, `@gladiaio/sdk` for JavaScript) open the session, keep the audio until it is transcribed and reconnect without losing a word ([SDKs](/introduction/sdks/)).

## At a glance

|  | Azure AI Speech | Gladia |
|---|---|---|
| Authentication | a resource key and region (`SpeechConfig(subscription=…, region=…)`) | `x-gladia-key: <key>`, one API address per region ([Regions](/introduction/regions/)) |
| Live | Speech SDK `SpeechRecognizer`, continuous recognition | `POST /v2/live` with a JSON body, then its WebSocket `url` |
| Pre-recorded | batch transcription REST (`/speechtotext/…/transcriptions`) | `POST /v2/upload`, `POST /v2/pre-recorded`, poll or callback |
| Audio | `PushAudioInputStream` | binary frames |
| Models | the base model per locale, or a custom model | `solaria-3` (multilingual), `trantoria-1` (lowest latency) ([Models](/introduction/models/)) |

## Live transcription

### Before and after

A typical Azure continuous recognition (Python, the Speech SDK):

```python
# Azure AI Speech (before)
import azure.cognitiveservices.speech as speechsdk

def stream(key, region, chunks):
    config = speechsdk.SpeechConfig(subscription=key, region=region)
    config.speech_recognition_language = "en-US"
    audio = speechsdk.audio.PushAudioInputStream(speechsdk.audio.AudioStreamFormat(samples_per_second=16000))
    recognizer = speechsdk.SpeechRecognizer(speech_config=config, audio_config=speechsdk.audio.AudioConfig(stream=audio))
    recognizer.recognizing.connect(lambda event: print("partial", event.result.text))
    recognizer.recognized.connect(lambda event: print("final", event.result.text))
    recognizer.start_continuous_recognition()
    for chunk in chunks:
        audio.write(chunk)
    audio.close()
    recognizer.stop_continuous_recognition()
```

With Gladia, the same stream: the SDK opens the session (`POST /v2/live`) and its WebSocket, and you send the same audio bytes. Put your Gladia API key in `GLADIA_API_KEY`, then run `python from_azure.py call.wav`.

```python title="from_azure.py"
# pip install -U "gladiaio-sdk>=2.2"
import os
import sys
import threading
import wave

from gladiaio_sdk import GladiaClient

API_URL = os.environ.get("GLADIA_API_URL", "https://eu1.api.gladia.io")
API_KEY = os.environ["GLADIA_API_KEY"]  # x-gladia-key, from Gladia Workspace

with wave.open(sys.argv[1]) as wav:  # a 16-bit PCM WAV file
    rate, channels = wav.getframerate(), wav.getnchannels()
    audio = wav.readframes(wav.getnframes())

config = {
    "encoding": "wav/pcm",
    "sample_rate": rate,
    "bit_depth": 16,
    "channels": channels,
    "model": "solaria-3",
    "language_config": {
        "languages": [
            "en"
        ]
    },
    "messages_config": {
        "receive_partial_transcripts": True
    }
}

client = GladiaClient(api_key=API_KEY, api_url=API_URL)
session = client.live_v2().start_session(config)  # POST /v2/live, then its WebSocket
ended, errors = threading.Event(), []

@session.on("message")
def on_message(message):
    if message.type == "transcript":  # Azure's "recognizing" and "recognized" events
        utterance = message.data.utterance
        print(("final  " if message.data.is_final else "partial ") + utterance.text)

session.on("error", errors.append)
session.once("ended", lambda _: ended.set())

# Stream once the socket is open: a stop sent while it opens can pass the audio queued until then.
connected = threading.Event()
session.once("connected", lambda _: connected.set())
session.once("ended", lambda _: connected.set())  # a session that never connects ends
session.on("error", lambda _: connected.set())
if session.status == "connected":  # it opened before the listener above
    connected.set()
if not connected.wait(timeout=30) or errors or ended.is_set():
    sys.exit(1)  # no open session to stream to

step = rate * channels * 2 // 10  # 100 ms of audio per chunk
for start in range(0, len(audio), step):
    session.send_audio(audio[start : start + step])  # binary frames, as before
session.stop_recording()  # closing Azure's push stream

ended.wait(timeout=60)
sys.exit(1 if errors or not ended.is_set() else 0)
```

The init body the program sends, as JSON:

```json
{
  "encoding": "wav/pcm",
  "sample_rate": 16000,
  "bit_depth": 16,
  "channels": 1,
  "model": "solaria-3",
  "language_config": {
    "languages": [
      "en"
    ]
  },
  "messages_config": {
    "receive_partial_transcripts": true
  }
}
```

### Parameters

| Azure AI Speech | Gladia | Note |
|---|---|---|
| `speech_recognition_language = "en-US"` | `language_config.languages: ["en"]` | ISO 639-1 codes ([Supported languages](/languages/supported-languages/)) |
| `AutoDetectSourceLanguageConfig`, continuous | `language_config: {"languages": […], "code_switching": true}` | [Code switching](/languages/code-switching/) |
| `AudioStreamFormat(samples_per_second, bits_per_sample, channels)` | `sample_rate`, `bit_depth`, `channels` |  |
| `PhraseListGrammar.add_phrase` | `realtime_processing.custom_vocabulary` and `realtime_processing.custom_vocabulary_config` | [Custom vocabulary](/features/custom-vocabulary/) |
| `ConversationTranscriber` | `diarization: true` | [Speaker diarization](/features/speaker-diarization/) |
| `Speech_SegmentationSilenceTimeoutMs` (ms) | `endpointing` (s) | [Endpointing](/live/endpointing/) |
| `TranslationRecognizer` | `realtime_processing.translation` | [Real-time translation](/features/translation/) |

### Messages

| Azure AI Speech | Gladia | Note |
|---|---|---|
| `recognizing` | `transcript`, `data.is_final: false` |  |
| `recognized` | `transcript`, `data.is_final: true` | the text: `data.utterance.text` |
| `speech_start_detected`, `speech_end_detected` | `speech_start`, `speech_end` |  |
| `session_stopped` | `end_session` | with `receive_lifecycle_events` |
| `canceled` | `error`, or the WebSocket's close code |  |

## Pre-recorded (batch) transcription

Azure's batch transcription takes `contentUrls` and writes its results as files you list and download. Gladia's job takes one `audio_url` (or an upload) and its result is in the job.

### Before and after

A typical Azure batch transcription (Python, the batch transcription REST API with `requests`; the file is in Blob Storage, read through a SAS URL):

```python
# Azure AI Speech (before)
import time

import requests

REGION = "westeurope"
SUBMIT = f"https://{REGION}.api.cognitive.microsoft.com/speechtotext/transcriptions:submit?api-version=2024-11-15"

def transcribe(key, sas_url):
    headers = {"Ocp-Apim-Subscription-Key": key}
    body = {
        "contentUrls": [sas_url],
        "locale": "en-US",
        "displayName": "call",
        "properties": {"diarizationEnabled": True, "timeToLiveHours": 48},
    }
    transcription = requests.post(SUBMIT, headers=headers, json=body).json()
    while transcription["status"] in ("NotStarted", "Running"):
        time.sleep(5)
        transcription = requests.get(transcription["self"], headers=headers).json()
    if transcription["status"] != "Succeeded":
        raise RuntimeError(transcription["status"])
    files = requests.get(transcription["links"]["files"], headers=headers).json()["values"]
    for file in files:  # the results are files to list, then download
        if file["kind"] == "Transcription":
            result = requests.get(file["links"]["contentUrl"]).json()
            print(result["combinedRecognizedPhrases"][0]["display"])
```

With Gladia, the same file in three steps: upload it (`POST /v2/upload`), start a job with its `audio_url` (`POST /v2/pre-recorded`), then read the job (`GET /v2/pre-recorded/{id}`) until its `status` is `done` ([Transcribe a file](/pre-recorded/transcribe-a-file/)). Put your Gladia API key in `GLADIA_API_KEY`, then run `python from_azure_file.py call.wav`.

```python title="from_azure_file.py"
# pip install requests
import os
import sys
import time

import requests

API_URL = os.environ.get("GLADIA_API_URL", "https://eu1.api.gladia.io")
HEADERS = {"x-gladia-key": os.environ["GLADIA_API_KEY"]}  # Azure: "Ocp-Apim-Subscription-Key: <key>"
TIMEOUT = 60  # seconds an HTTP call may take
POLL_EVERY = 1  # seconds between two reads of the job
ENDED = ("done", "error")  # the statuses a job ends with

# 1. Upload the file (or give your SAS URL as audio_url, as in contentUrls)
with open(sys.argv[1], "rb") as audio:
    upload = requests.post(f"{API_URL}/v2/upload", headers=HEADERS, files={"audio": audio}, timeout=TIMEOUT)
upload.raise_for_status()

# 2. Start the job on the uploaded file, the options in a JSON body
created = requests.post(
    f"{API_URL}/v2/pre-recorded",
    headers=HEADERS,
    json={
        "audio_url": upload.json()["audio_url"],
        "model": "solaria-3",  # the locale's base model
        "language_config": {"languages": ["en"]},  # locale: "en-US"
        "diarization": True,  # properties.diarizationEnabled
    },
    timeout=TIMEOUT,
)
created.raise_for_status()
job_url = f"{API_URL}/v2/pre-recorded/{created.json()['id']}"

# 3. Read the job until it ends (or get a callback, below)
while True:
    answer = requests.get(job_url, headers=HEADERS, timeout=TIMEOUT)
    answer.raise_for_status()
    job = answer.json()
    if job["status"] in ENDED:
        break
    time.sleep(POLL_EVERY)
if job["status"] == "error":
    sys.exit(f"the job failed: {job.get('error_code')}")
print(job["result"]["transcription"]["full_transcript"])  # the result is in the job
```

To be called back rather than poll, add a callback to the job: Gladia calls your URL when the job ends ([Pre-recorded callbacks](/pre-recorded/callbacks/)). The job's body, with a callback:

```json
{
  "audio_url": "https://eu1.api.gladia.io/file/0199d7a2-0000-7000-8000-00000000f11e",
  "language_config": {
    "languages": [
      "en"
    ]
  },
  "diarization": true,
  "callback": true,
  "callback_config": {
    "url": "https://example.com/gladia/callback"
  }
}
```

| Azure AI Speech | Gladia | Note |
|---|---|---|
| `contentUrls` | `audio_url` | one file per job |
| `locale` | `language_config.languages` |  |
| `properties.diarizationEnabled` | `diarization` |  |
| `properties.channels` | the file's channels, each transcribed | [Several channels](/live/multichannel/) |
| the results files (`combinedRecognizedPhrases`) | `result.transcription.full_transcript`, `utterances` |  |
| polling the transcription's `status` | `callback_config.url`, or polling the job |  |

## Differences to know

- **A session is opened over HTTP first.** `POST /v2/live` with the session's settings returns a WebSocket `url` that carries its own token: settings go in a JSON body, not in the WebSocket's query string, and your API key never reaches the client that streams. The SDKs do both steps.
- **Endpointing is in seconds**: `endpointing: 0.3` is 300 ms ([Endpointing](/live/endpointing/)).
- **Punctuation and casing are on by default** ([Punctuation](/features/punctuation/)); numbers as digits are `numerals: true` ([Numbers as digits](/features/numerals/)).
- **Audio is acknowledged once transcribed**, not once received: keep it until then to resend it after a network drop ([Reconnections](/live/reconnections/)). The SDKs do it for you.
- **Language codes are ISO 639-1**: `en`, not `en-US`.
- **No resource key and region pair**: one API key per workspace, and the API address of your region.

## Related pages

- [Quickstart: live speech-to-text in five minutes](/introduction/quickstart/)
- [Live transcription over WebSocket: how a session works](/live/how-it-works/)
- [Pre-recorded (batch) transcription of an audio file](/pre-recorded/transcribe-a-file/)
- [Recommended parameters](/live/recommended-parameters/)
