将自定义端点与 Speech-to-Text API 一起使用

此示例展示了如何将自定义端点与 Speech-to-Text API 搭配使用。如果您想使用位于应用所在区域之外的 Speech-to-Text API 端点,此功能会非常有用。

代码示例

Python

如需了解如何安装和使用 Speech-to-Text 客户端库,请参阅 Speech-to-Text 客户端库。 如需了解详情,请参阅 Speech-to-Text Python API 参考文档

如需向 Speech-to-Text 进行身份验证,请设置应用默认凭证。 如需了解详情,请参阅为本地开发环境设置身份验证


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

后续步骤

如需搜索和过滤其他 Google Cloud 产品的代码示例,请参阅Google Cloud 示例浏览器