简体   繁体   中英

Google Cloud Text To Speech REST API Authentication

So I want to use the Google Cloud Text to Speech using a simple POST request from my C++ program, the problem is with their authentication. I did create a service account as they mentioned and I got the file containing my private key. But I don't know how can I use it in my POST request to be authenticated ?

POST Url: https://texttospeech.googleapis.com/v1beta1/text:synthesize and here is my POST body:

{ "audioConfig": { "audioEncoding": "LINEAR16", "pitch": "0.00", "speakingRate": "1.00" }, "input": { "text": "Hello World" }, "voice": { "languageCode": "en-US", "name": "en-US-Wavenet-E" } }

您必须将环境变量GOOGLE_APPLICATION_CREDENTIALS设置为包含服务帐户密钥的JSON文件的路径。

I found out that I need to create an API Key Credential from the following link: https://console.developers.google.com/apis/credentials?project=[your-project-name]

and then append "?key=[API_KEY]" to my POST url and the authentication problem is fixed !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM