Regionalen Endpunkt angeben
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Text-to-Speech bietet regionale API-Endpunkte für die USA und EU.
Wenn Sie einen regionalen Endpunkt verwenden, bleiben Ihre inaktiven und verwendeten Daten innerhalb der kontinentalen Grenzen von Europa oder den USA. Die Angabe eines Endpunkts ist wichtig, wenn der Standort Ihrer Daten lokalen gesetzlichen Anforderungen genügen muss. Das Verhalten der API bleibt unverändert.
Regionale Endpunkte verwenden
Wenn Sie einen regionalen Endpunkt verwenden, müssen Sie den entsprechenden us
- oder eu
-Standort in den parent
-String aufnehmen. Weitere Informationen zum Konfigurieren des Texts der Synthetisierungsanfrage finden Sie in der Synthesize
-Dokumentation.
Protokoll
Um eine synthetische Sprachausgabe mit einem regionalen Endpunkt zu erstellen führen Sie den entsprechenden Befehl in der folgenden Tabelle aus, um den benötigten Endpunkt zu konfigurieren:
Mehrere Regionen |
Endpunktüberschreibung |
EU |
$ export CLOUD_TTS_ENDPOINT=https://eu-texttospeech.googleapis.com |
USA |
$ export CLOUD_TTS_ENDPOINT=https://us-texttospeech.googleapis.com |
An diesen Endpunkten sind nur Neural2-Stimmen verfügbar:
Eine Region |
Endpunktüberschreibung |
US Central1 |
$ export CLOUD_TTS_ENDPOINT=https://us-central1-texttospeech.googleapis.com |
Im folgenden Codebeispiel wird gezeigt, wie Sie ein synthesis request
senden, das alle Daten auf eine bestimmte Region beschränkt. Sie können den regionalen EU
- oder US
-Endpunkt durch die CLOUD_TTS_ENDPOINT-Variable ersetzen. Ersetzen Sie PROJECT_ID durch Ihre Projekt-ID.
$ curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "x-goog-user-project: PROJECT_ID" \
-H "Content-Type: application/json; charset=utf-8" \
--data "{
'input':{
'text':'Android is a mobile operating system developed by Google,
based on the Linux kernel and designed primarily for
touchscreen mobile devices such as smartphones and tablets.'
},
'voice':{
'languageCode':'en-gb',
'name':'en-GB-Neural2-A',
'ssmlGender':'FEMALE'
},
'audioConfig':{
'audioEncoding':'MP3'
}
}" $CLOUD_TTS_ENDPOINT/v1/text:synthesize > synthesize-text.txt
In diesem Beispiel wird mit der Google Cloud CLI ein Zugriffstoken für Ihr Google-Konto erstellt. Eine Anleitung zur Installation der gcloud CLI finden Sie unter Bei Text-to-Speech authentifizieren.
Nutzung globaler API-Endpunkt einschränken
Um die Verwendung regionaler Endpunkte zu erzwingen, können Sie die Organisationsrichtlinieneinschränkung constraints/gcp.restrictEndpointUsage
verwenden, um Anfragen an den globalen API-Endpunkt zu blockieren. Weitere Informationen finden Sie unter Endpunktnutzung einschränken.
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
Zuletzt aktualisiert: 2025-08-11 (UTC).
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-08-11 (UTC)."],[],[],null,["# Specify a regional endpoint\n\nText-to-Speech 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[`Synthesize`](/text-to-speech/docs/create-audio)\ndocumentation for more information about configuring the synthesize request\nbody. \n\n### Protocol\n\nTo perform text to speech synthesis using a regional endpoint, run the\napplicable command in the table below to configure the correct endpoint:\n\nOnly Neural2 voices are available from these endpoints:\n\nThe following code sample demonstrates how to send a\n[`synthesis request`](/text-to-speech/docs/reference/rest/v1beta1/text/synthesize)\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_TTS_ENDPOINT\u003c/var\u003e\nvariable. Replace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with your project ID. \n\n```bash\n$ curl -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"x-goog-user-project: \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e\" \\\n -H \"Content-Type: application/json; charset=utf-8\" \\\n --data \"{\n 'input':{\n 'text':'Android is a mobile operating system developed by Google,\n based on the Linux kernel and designed primarily for\n touchscreen mobile devices such as smartphones and tablets.'\n },\n 'voice':{\n 'languageCode':'en-gb',\n 'name':'en-GB-Neural2-A',\n 'ssmlGender':'FEMALE'\n },\n 'audioConfig':{\n 'audioEncoding':'MP3'\n }\n }\" $\u003cvar translate=\"no\"\u003eCLOUD_TTS_ENDPOINT\u003c/var\u003e/v1/text:synthesize \u003e synthesize-text.txt\n```\n\nThis example uses the [Google Cloud CLI](/sdk/docs/install) to create an access\ntoken for your Google Account. For instructions on installing the\ngcloud CLI, see\n[Authenticate to Text-to-Speech](/text-to-speech/docs/authentication).\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\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)."]]