# Migrate from Google Cloud Speech-to-Text to Gladia

Last updated: 2026-11-12

Google Cloud Speech-to-Text streams over gRPC with a `StreamingRecognize` call whose first request carries the configuration; Gladia opens the session over HTTP, then streams over a WebSocket. Results with `is_final` become `transcript` messages with `is_final`. Batch recognition becomes 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

|  | Google Cloud Speech-to-Text | Gladia |
|---|---|---|
| Authentication | a Google Cloud service account (OAuth) | `x-gladia-key: <key>` |
| Live | gRPC `StreamingRecognize` (v2) | `POST /v2/live` with a JSON body, then its WebSocket `url` |
| Pre-recorded | `BatchRecognize` from Cloud Storage, or `Recognize` for short audio | `POST /v2/upload`, `POST /v2/pre-recorded`, poll or callback |
| Audio | `StreamingRecognizeRequest.audio` | binary frames |
| Models | `long`, `short`, `telephony`, `chirp_2`, … | `solaria-3` (multilingual), `trantoria-1` (lowest latency) ([Models](/introduction/models/)) |

## Live transcription

### Before and after

A typical Google Speech-to-Text v2 stream (Python, `google-cloud-speech`):

```python
# Google Cloud Speech-to-Text v2 (before)
from google.cloud.speech_v2 import SpeechClient
from google.cloud.speech_v2.types import cloud_speech

def stream(project, chunks):
    config = cloud_speech.RecognitionConfig(
        explicit_decoding_config=cloud_speech.ExplicitDecodingConfig(
            encoding=cloud_speech.ExplicitDecodingConfig.AudioEncoding.LINEAR16,
            sample_rate_hertz=16000,
            audio_channel_count=1,
        ),
        language_codes=["en-US"],
        model="long",
    )
    streaming_config = cloud_speech.StreamingRecognitionConfig(
        config=config, streaming_features=cloud_speech.StreamingRecognitionFeatures(interim_results=True)
    )
    first = cloud_speech.StreamingRecognizeRequest(
        recognizer=f"projects/{project}/locations/global/recognizers/_", streaming_config=streaming_config
    )
    requests = [first, *(cloud_speech.StreamingRecognizeRequest(audio=chunk) for chunk in chunks)]
    for response in SpeechClient().streaming_recognize(requests=iter(requests)):
        for result in response.results:
            print("final" if result.is_final else "partial", result.alternatives[0].transcript)
```

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_google.py call.wav`.

```python title="from_google.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":  # Google's results, "is_final" true or false
        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()  # the end of Google's request 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

| Google Cloud Speech-to-Text | Gladia | Note |
|---|---|---|
| `language_codes: ["en-US"]` | `language_config.languages: ["en"]` | ISO 639-1 codes |
| several `language_codes` | `language_config: {"languages": […], "code_switching": true}` | [Code switching](/languages/code-switching/) |
| `explicit_decoding_config` (`LINEAR16`, `MULAW`) | `encoding` (`wav/pcm`, `wav/ulaw`), `bit_depth` | [Phone calls](/live/telephony/) |
| `sample_rate_hertz`, `audio_channel_count` | `sample_rate`, `channels` |  |
| `model` | `model` | `solaria-3` or `trantoria-1` |
| `interim_results: true` | `messages_config.receive_partial_transcripts: true` | [Partial transcripts](/live/partial-transcripts/) |
| `enable_voice_activity_events` | `messages_config.receive_speech_events: true` | `speech_start`, `speech_end` |
| `features.enable_automatic_punctuation` | on by default (`punctuation`) |  |
| `features.diarization_config` | `diarization: true`, `diarization_config` | [Speaker diarization](/features/speaker-diarization/) |
| `adaptation` (phrase sets) | `realtime_processing.custom_vocabulary` and `realtime_processing.custom_vocabulary_config` | [Custom vocabulary](/features/custom-vocabulary/) |

### Messages

| Google Cloud Speech-to-Text | Gladia | Note |
|---|---|---|
| `results[].is_final: false` | `transcript`, `data.is_final: false` |  |
| `results[].is_final: true` | `transcript`, `data.is_final: true` | the text: `data.utterance.text` |
| `alternatives[0].words` | `data.utterance.words` |  |
| `SPEECH_ACTIVITY_BEGIN`, `SPEECH_ACTIVITY_END` | `speech_start`, `speech_end` |  |
| end of the response stream | `end_session` | with `receive_lifecycle_events` |

## Pre-recorded (batch) transcription

Google's `BatchRecognize` reads files from Cloud Storage and writes or returns its results per file. A Gladia job reads any URL (a signed Cloud Storage URL works) or an upload.

### Before and after

A typical Google Speech-to-Text v2 batch recognition (Python, `google-cloud-speech`; the file is in Cloud Storage):

```python
# Google Cloud Speech-to-Text v2 (before)
from google.cloud.speech_v2 import SpeechClient
from google.cloud.speech_v2.types import cloud_speech

def transcribe(project, gcs_uri):
    config = cloud_speech.RecognitionConfig(
        auto_decoding_config=cloud_speech.AutoDetectDecodingConfig(),
        language_codes=["en-US"],
        model="long",
    )
    request = cloud_speech.BatchRecognizeRequest(
        recognizer=f"projects/{project}/locations/global/recognizers/_",
        config=config,
        files=[cloud_speech.BatchRecognizeFileMetadata(uri=gcs_uri)],  # gs://bucket/call.wav
        recognition_output_config=cloud_speech.RecognitionOutputConfig(
            inline_response_config=cloud_speech.InlineOutputConfig()
        ),
    )
    operation = SpeechClient().batch_recognize(request=request)  # a long-running operation
    response = operation.result(timeout=600)
    for result in response.results[gcs_uri].transcript.results:
        if result.alternatives:
            print(result.alternatives[0].transcript)
```

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_google_file.py call.wav`.

```python title="from_google_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"]}  # Google: a service account (OAuth)
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 a signed Cloud Storage URL as audio_url)
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",  # model="long"
        "language_config": {"languages": ["en"]},  # language_codes=["en-US"]
    },
    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"
  }
}
```

| Google Cloud Speech-to-Text | Gladia | Note |
|---|---|---|
| `files[].uri` (`gs://…`) | `audio_url` (a signed `https://` URL), or `POST /v2/upload` |  |
| `config.language_codes` | `language_config.languages` |  |
| `config.features.diarization_config` | `diarization`, `diarization_config` |  |
| polling the long-running operation | `GET /v2/pre-recorded/{id}`, or a callback |  |
| `results[].alternatives[0].transcript` | `result.transcription.utterances[].text` | the whole text: `full_transcript` |

## 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.
- **One session per call**: a live session runs up to 8 hours by default ([Rate limits and quotas](/limits/concurrency/)), so a call needs no stream restarted and stitched every few minutes.
- **No recognizer or Cloud Storage to set up**: an API key, then the request.

## 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/)
