Especificar um endpoint regional
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
A Text-to-Speech oferece endpoints de API regionais dos EUA e da UE.
Se você usar um endpoint regional, os dados em repouso e em uso vão permanecer
dentro dos limites continentais da Europa ou dos EUA. Especificar um endpoint
é importante se o local dos dados precisar ser controlado para cumprir
os requisitos regulamentares locais. Não há alteração funcional no comportamento da
API.
Ao usar um endpoint regional, inclua o local us
ou eu
correspondente na string parent
. Consulte a
documentação Synthesize
para mais informações sobre como configurar o corpo da solicitação
de sintetização.
Protocolo
Para executar a síntese da conversão de texto em voz usando um endpoint regional, execute o
comando aplicável na tabela abaixo para configurar o endpoint correto:
Multirregional |
Modificação do endpoint |
UE |
$ export CLOUD_TTS_ENDPOINT=https://eu-texttospeech.googleapis.com |
EUA |
$ export CLOUD_TTS_ENDPOINT=https://us-texttospeech.googleapis.com |
Somente as vozes Neural2 estão disponíveis nestes endpoints:
Única região |
Modificação do endpoint |
US Central1 |
$ export CLOUD_TTS_ENDPOINT=https://us-central1-texttospeech.googleapis.com |
O exemplo de código a seguir demonstra como enviar um
synthesis request
que mantém todos os dados restritos a uma região específica. É possível substituir o endpoint
regional EU
ou US
pela
variável CLOUD_TTS_ENDPOINT. Substitua PROJECT_ID pelo ID do projeto.
$ 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
Este exemplo usa a CLI do Google Cloud para criar um token de acesso para sua Conta do Google. Para instruções sobre como instalar a
gcloud CLI, consulte
Autenticar na Text-to-Speech.
Exceto em caso de indicação contrária, o conteúdo desta página é licenciado de acordo com a Licença de atribuição 4.0 do Creative Commons, e as amostras de código são licenciadas de acordo com a Licença Apache 2.0. Para mais detalhes, consulte as políticas do site do Google Developers. Java é uma marca registrada da Oracle e/ou afiliadas.
Última atualização 2025-02-01 UTC.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-02-01 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)."]]