Speech-to-Text는 미국 및 EU 리전 API 엔드포인트를 제공합니다.
리전 엔드포인트를 사용할 경우 저장 데이터 및 사용 중인 데이터는 유럽 또는 미국의 대륙 경계 내에 유지됩니다. 엔드포인트 지정은 현지 규제 요건을 준수하기 위해 데이터 위치를 제어해야 하는 경우에 중요합니다. API의 동작에 대한 기능 변경사항은 없습니다.
리전 엔드포인트 사용
리전 엔드포인트를 사용하는 경우 parent 문자열에 일치하는 us 또는 eu 위치를 포함해야 합니다. 인식 요청 본문 구성에 대한 자세한 내용은 RecognitionConfig 문서를 참조하세요.
프로토콜
리전 엔드포인트를 사용하여 음성 인식을 수행하려면 아래 표에서 해당 명령어를 실행하여 올바른 엔드포인트를 구성합니다.
Speech-to-Text에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다.
자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.
# 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
전역 API 엔드포인트 사용 제한
리전 엔드포인트 사용을 강제하려면 constraints/gcp.restrictEndpointUsage 조직 정책 제약 조건을 사용하여 전역 API 엔드포인트에 대한 요청을 차단하세요. 자세한 내용은 엔드포인트 사용 제한을 참고하세요.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-16(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)."]]