Google Cloud Text To Speech REST API Authentication

♀尐吖头ヾ 提交于 2019-12-12 01:23:02

问题


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" } }


回答1:


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 !




回答2:


You have to set the environment variable GOOGLE_APPLICATION_CREDENTIALS to the path of the JSON file that contains your service account key.



来源:https://stackoverflow.com/questions/53810752/google-cloud-text-to-speech-rest-api-authentication

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!