Stay organized with collections
Save and categorize content based on your preferences.
Speech-to-Text offers US and EU regional API endpoints.
If you use a regional endpoint, your data at-rest and in-use will stay
within the continental boundaries of Europe or the USA. Specifying an endpoint
is important if your data's location must be controlled in order to comply with
local regulatory requirements. There is no functional change to the behavior of
the API.
Use regional endpoints
When you use a regional endpoint, make sure to include the matching us or eu
location in the parent string. See the
RecognitionConfig
documentation for more information about configuring the recognition request
body.
Protocol
To perform speech recognition using a regional endpoint, run the
applicable command in the table below to configure the correct endpoint:
The following code sample demonstrates how to send a
recognize request
that keeps all data confined to a specified region. You can substitute either
the EU or US regional endpoint for the CLOUD_SPEECH_ENDPOINT
variable.
This example uses Google Cloud CLI to generate
credentials for your user account. To learn how to install and initialize the
gcloud CLI, see the
quickstart.
The audio content supplied in the request body is base64-encoded.
For more information on how to base64-encode audio, see
Base64 Encoding Audio Content. For more information on the
content field, see
RecognitionAudio.
gcloud
The following commands set a regional endpoint:
Multi-region
Endpoint override
EU
gcloud config set api_endpoint_overrides/speech https://eu-speech.googleapis.com/
US
gcloud config set api_endpoint_overrides/speech https://us-speech.googleapis.com/
After you set the regional endpoint, all data will be confined to the specified
region when you send subsequent recognize requests.
The following example demonstrates a recognize request.
# Imports the Google Cloud client libraryfromgoogle.api_coreimportclient_optionsfromgoogle.cloudimportspeechdefsync_recognize_with_multi_region_gcs()-> speech.RecognizeResponse:"""Recognizes speech synchronously in the GCS bucket."""# Instantiates a client# Pass an additional argument, ClientOptions, to specify the new endpoint._client_options=client_options.ClientOptions(api_endpoint="eu-speech.googleapis.com")client=speech.SpeechClient(client_options=_client_options)# The name of the audio file to transcribegcs_uri="gs://cloud-samples-data/speech/brooklyn_bridge.raw"audio=speech.RecognitionAudio(uri=gcs_uri)config=speech.RecognitionConfig(encoding=speech.RecognitionConfig.AudioEncoding.LINEAR16,sample_rate_hertz=16000,language_code="en-US",)# Detects speech in the audio fileresponse=client.recognize(config=config,audio=audio)forresultinresponse.results:print(f"Transcript: {result.alternatives[0].transcript}")returnresponse.results
Restrict global API endpoint usage
To help enforce the use of regional endpoints, use the
constraints/gcp.restrictEndpointUsage organization policy constraint to block
requests to the global API endpoint. For more information, see
Restricting endpoint usage.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Specify a regional endpoint\n\nSpeech-to-Text offers US and EU regional API endpoints.\nIf you use a regional endpoint, your data at-rest and in-use will stay\nwithin the continental boundaries of Europe or the USA. Specifying an endpoint\nis important if your data's location must be controlled in order to comply with\nlocal regulatory requirements. There is no functional change to the behavior of\nthe API.\n\nUse regional endpoints\n----------------------\n\nWhen you use a regional endpoint, make sure to include the matching `us` or `eu`\nlocation in the `parent` string. See the\n[`RecognitionConfig`](/speech-to-text/docs/reference/rest/v1/RecognitionConfig)\ndocumentation for more information about configuring the recognition request\nbody. \n\n### Protocol\n\nTo perform speech recognition using a regional endpoint, run the\napplicable command in the table below to configure the correct endpoint:\n\nThe following code sample demonstrates how to send a\n[`recognize request`](/sdk/gcloud/reference/ml/speech/recognize)\nthat keeps all data confined to a specified region. You can substitute either\nthe `EU` or `US` regional endpoint for the \u003cvar translate=\"no\"\u003eCLOUD_SPEECH_ENDPOINT\u003c/var\u003e\nvariable. \n\n```bash\n$ curl -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer \"$(gcloud auth print-access-token) \\\n $\u003cvar translate=\"no\"\u003eCLOUD_SPEECH_ENDPOINT\u003c/var\u003e/v1/speech:recognize \\\n --data \"{\n 'config': {\n 'encoding': 'LINEAR16',\n 'languageCode': 'en-US'\n },\n 'audio': {\n 'uri':'gs://speech-samples-00/commercial_mono.wav'\n }\n }\"\n```\n\nThis example uses [Google Cloud CLI](/sdk/docs/install) to generate\ncredentials for your user account. To learn how to install and initialize the\ngcloud CLI, see the\n[quickstart](/speech-to-text/docs/transcribe-api).\n\nThe audio content supplied in the request body is base64-encoded.\nFor more information on how to base64-encode audio, see\n[Base64 Encoding Audio Content](/speech-to-text/docs/base64-encoding). For more information on the\n`content` field, see\n[RecognitionAudio](/speech-to-text/docs/reference/rest/v1/RecognitionAudio).\n\n### gcloud\n\nThe following commands set a regional endpoint:\n\nAfter you set the regional endpoint, all data will be confined to the specified\nregion when you send subsequent [`recognize requests`](/sdk/gcloud/reference/ml/speech/recognize).\nThe following example demonstrates a recognize request. \n\n```bash\n$ gcloud ml speech recognize gs://cloud-samples-tests/speech/brooklyn.flac \\\n --language-code=en-US --log-http\n```\n\n### Python\n\n\nTo learn how to install and use the client library for Speech-to-Text, see\n[Speech-to-Text client libraries](/speech-to-text/docs/client-libraries).\n\n\nFor more information, see the\n[Speech-to-Text Python API\nreference documentation](/python/docs/reference/speech/latest).\n\n\nTo authenticate to Speech-to-Text, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n\n # Imports the Google Cloud client library\n from google.api_core import client_options\n from google.cloud import speech\n\n\n def sync_recognize_with_multi_region_gcs() -\u003e speech.RecognizeResponse:\n \"\"\"Recognizes speech synchronously in the GCS bucket.\"\"\"\n\n # Instantiates a client\n\n # Pass an additional argument, ClientOptions, to specify the new endpoint.\n _client_options = client_options.ClientOptions(\n api_endpoint=\"eu-speech.googleapis.com\"\n )\n\n client = speech.SpeechClient(client_options=_client_options)\n\n # The name of the audio file to transcribe\n gcs_uri = \"gs://cloud-samples-data/speech/brooklyn_bridge.raw\"\n\n audio = speech.RecognitionAudio(uri=gcs_uri)\n\n config = speech.RecognitionConfig(\n encoding=speech.RecognitionConfig.AudioEncoding.LINEAR16,\n sample_rate_hertz=16000,\n language_code=\"en-US\",\n )\n\n # Detects speech in the audio file\n response = client.recognize(config=config, audio=audio)\n\n for result in response.results:\n print(f\"Transcript: {result.alternatives[0].transcript}\")\n\n return response.results\n\n\u003cbr /\u003e\n\nRestrict global API endpoint usage\n----------------------------------\n\nTo help enforce the use of regional endpoints, use the\n`constraints/gcp.restrictEndpointUsage` organization policy constraint to block\nrequests to the global API endpoint. For more information, see\n[Restricting endpoint usage](/assured-workloads/docs/restrict-endpoint-usage)."]]