搭配 Speech-to-Text API 使用自訂端點

這個範例說明如何搭配 Speech-to-Text API 使用自訂端點。如果您想使用與應用程式位於不同地區的 Speech-to-Text API 端點,這項功能會很實用。

程式碼範例

Python

如要瞭解如何安裝及使用 Speech-to-Text 的用戶端程式庫,請參閱這篇文章。 詳情請參閱 Speech-to-Text Python API 參考說明文件

如要向語音轉文字服務進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。


# 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 範例瀏覽器