简体   繁体   English

Google Cloud Text To Speech REST API身份验证

[英]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. 因此,我想使用来自我的C ++程序的简单POST请求来使用Google Cloud Text to Speech,问题在于它们的身份验证。 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请求中使用它进行身份验证?

POST Url: https://texttospeech.googleapis.com/v1beta1/text:synthesize and here is my POST body: POST网址: https ://texttospeech.googleapis.com/v1beta1/text: synthesize ,这是我的POST正文:

{ "audioConfig": { "audioEncoding": "LINEAR16", "pitch": "0.00", "speakingRate": "1.00" }, "input": { "text": "Hello World" }, "voice": { "languageCode": "en-US", "name": "en-US-Wavenet-E" } } {“ 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] 我发现我需要通过以下链接创建API密钥凭证: 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 ! 然后将“?key = [API_KEY]”附加到我的POST网址中,从而解决了身份验证问题!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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