Migrate from Whisper to Gladia
Whisper transcribes files: you run the model on your own GPUs, or send each file to OpenAI’s /v1/audio/transcriptions. Moving to Gladia removes the GPUs and the queue you run, adds speaker diarization and personal data redaction to the same request, and opens live streaming, which Whisper does not do. 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).
At a glance
Section titled “At a glance”| Whisper | Gladia | |
|---|---|---|
| Authentication | your servers, or Authorization: Bearer <OpenAI key> |
x-gladia-key: <key> |
| Live | none: your own loop transcribes chunks of audio | POST /v2/live with a JSON body, then its WebSocket url |
| Pre-recorded | model.transcribe(path), or POST /v1/audio/transcriptions, the transcript in the answer |
POST /v2/upload, POST /v2/pre-recorded, poll or callback |
| Audio | a file, or an array of samples | binary frames (live), a file or a URL (pre-recorded) |
| Speakers | none | diarization: true |
| Models | large-v3, whisper-1, … |
solaria-3 (multilingual), trantoria-1 (lowest latency) (Models) |
Live transcription
Section titled “Live transcription”Whisper has no live mode: a self-hosted setup cuts the audio into chunks and transcribes each one, so every word waits for the end of its chunk, and a word cut in two by a chunk boundary is often lost. Gladia streams instead: send the audio as it is captured and receive each utterance a fraction of a second after it is spoken.
Before and after
Section titled “Before and after”A typical self-hosted loop (Python, the openai-whisper package):
# Whisper, self-hosted (before)import numpy as npimport whisper
model = whisper.load_model("large-v3")CHUNK = 16000 * 2 * 5 # 5 s of 16 kHz, 16-bit mono audio
def stream(chunks): buffer = b"" for chunk in chunks: # audio as it is captured buffer += chunk if len(buffer) >= CHUNK: # transcribe once 5 s have piled up samples = np.frombuffer(buffer, np.int16).astype(np.float32) / 32768 print(model.transcribe(samples, language="en", initial_prompt="Gladia, Kubernetes")["text"]) buffer = b""With Gladia, the SDK opens the session (POST /v2/live) and its WebSocket, and you send the audio as it comes: no chunking, no buffer. Put your Gladia API key in GLADIA_API_KEY, then run python from_whisper.py call.wav.
# pip install -U "gladiaio-sdk>=2.2"import osimport sysimport threadingimport 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" ] }, "endpointing": 0.3, "realtime_processing": { "custom_vocabulary": True, "custom_vocabulary_config": { "vocabulary": [ "Gladia", "Kubernetes" ] } }}
client = GladiaClient(api_key=API_KEY, api_url=API_URL)session = client.live_v2().start_session(config) # POST /v2/live, then its WebSocketended, errors = threading.Event(), []
@session.on("message")def on_message(message): if message.type == "transcript" and message.data.is_final: # one per utterance print(message.data.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 endssession.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 chunkfor start in range(0, len(audio), step): session.send_audio(audio[start : start + step]) # as it is captured, no buffersession.stop_recording() # the end of the audio
ended.wait(timeout=60)sys.exit(1 if errors or not ended.is_set() else 0)The init body the program sends, as JSON:
{ "encoding": "wav/pcm", "sample_rate": 16000, "bit_depth": 16, "channels": 1, "model": "solaria-3", "language_config": { "languages": [ "en" ] }, "endpointing": 0.3, "realtime_processing": { "custom_vocabulary": true, "custom_vocabulary_config": { "vocabulary": [ "Gladia", "Kubernetes" ] } }}Parameters
Section titled “Parameters”| Whisper | Gladia | Note |
|---|---|---|
language="en" |
language_config.languages: ["en"] |
|
language=None (detected) |
language_config.languages: [] |
add code_switching: true when speakers switch (Code switching) |
initial_prompt (names, jargon) |
realtime_processing.custom_vocabulary and realtime_processing.custom_vocabulary_config |
Custom vocabulary |
task="translate" |
realtime_processing.translation and realtime_processing.translation_config.target_languages |
into any target language, not only English (Real-time translation) |
| your chunk length and your VAD | endpointing (s) |
the silence that closes an utterance (Endpointing) |
word_timestamps=True |
always: data.utterance.words |
Results
Section titled “Results”| Whisper | Gladia | Note |
|---|---|---|
the text of a chunk |
transcript with data.is_final: true |
the text: data.utterance.text; one per utterance, never revised |
| none: a chunk is final when transcribed | transcript with data.is_final: false |
with messages_config.receive_partial_transcripts (Partial transcripts) |
segments[].start, segments[].end |
data.utterance.start, data.utterance.end |
seconds from the start of the session’s audio |
| none | end_of_turn |
with end_of_turn: true, when the speaker’s turn is over (End of turn) |
Pre-recorded (batch) transcription
Section titled “Pre-recorded (batch) transcription”Whisper transcribes a file in one call, self-hosted or through OpenAI, and returns its text. Gladia runs a job, so a long file never holds a request open, and the same job can label the speakers.
Before and after
Section titled “Before and after”A file transcribed by Whisper, self-hosted or through OpenAI (Python):
# Whisper, self-hosted or through OpenAI (before)import whisperfrom openai import OpenAI
# self-hostedtext = whisper.load_model("large-v3").transcribe("call.wav", language="en", initial_prompt="Gladia, Kubernetes")["text"]
# through OpenAI's APIwith open("call.wav", "rb") as audio: text = OpenAI().audio.transcriptions.create(model="whisper-1", file=audio, language="en", prompt="Gladia, Kubernetes").textWith 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). Put your Gladia API key in GLADIA_API_KEY, then run python from_whisper_file.py call.wav.
# pip install requestsimport osimport sysimport 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"]} # OpenAI: "Authorization: Bearer <key>"TIMEOUT = 60 # seconds an HTTP call may takePOLL_EVERY = 1 # seconds between two reads of the jobENDED = ("done", "error") # the statuses a job ends with
# 1. Upload the file (OpenAI takes it in the request itself)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 bodycreated = requests.post( f"{API_URL}/v2/pre-recorded", headers=HEADERS, json={ "audio_url": upload.json()["audio_url"], "model": "solaria-3", "language_config": {"languages": ["en"]}, # language="en" "custom_vocabulary": True, # prompt="Gladia, Kubernetes" "custom_vocabulary_config": {"vocabulary": ["Gladia", "Kubernetes"]}, "diarization": True, # speakers, which Whisper does not label }, 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"]) # Whisper's "text"To be called back rather than poll, add a callback to the job: Gladia calls your URL when the job ends (Pre-recorded callbacks). The job’s body, with a callback:
{ "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" }, "custom_vocabulary": true, "custom_vocabulary_config": { "vocabulary": [ "Gladia", "Kubernetes" ] }}| Whisper | Gladia | Note |
|---|---|---|
| the file | POST /v2/upload, or a public audio_url |
up to 1000 MB and 2 h 15 min per file (Pre-recorded limits) |
language |
language_config.languages |
[] to detect it |
initial_prompt / prompt |
custom_vocabulary, custom_vocabulary_config |
words to get right, not a free prompt |
task="translate", /v1/audio/translations |
translation, translation_config.target_languages |
into any target language, not only English |
text |
result.transcription.full_transcript |
|
segments (response_format="verbose_json") |
result.transcription.utterances |
each with its speaker, with diarization |
timestamp_granularities=["word"] |
result.transcription.utterances[].words |
always there |
response_format="srt", "vtt" |
subtitles: true, subtitles_config.formats |
Add-ons |
Differences to know
Section titled “Differences to know”- A job, not a call: upload, start the job, then read it when its callback arrives or by polling (Transcribe a file).
- Bigger files: up to 1000 MB and 2 h 15 min of audio per file, where OpenAI’s API takes 25 MB. Past them, Gladia answers
413: split the file, or ask for a higher limit for your workspace (Pre-recorded limits). - Speakers come with it:
diarization: truelabels each utterance; with Whisper it was another model to run. - A prompt is a vocabulary: list the names and terms to get right; free-text instructions are not read.
- Live is new: Whisper never streamed. Each utterance is final once sent, so there is no chunk to stitch back together; start from the Quickstart.
- No GPU to run: Gladia scales the transcription for you, within your workspace’s concurrency (Rate limits and quotas):
429means you reached it.