Use a custom endpoint with the Speech-to-Text API

This sample shows you how to use a custom endpoint with the Speech-to-Text API. This can be useful if you want to use a Speech-to-Text API endpoint that is located in a different region than your application.

Code sample

Python

To learn how to install and use the client library for Cloud STT, see Cloud STT client libraries. For more information, see the Cloud STT Python API reference documentation.

To authenticate to Cloud STT, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.


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

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.