Google Cloud Text-to-Speech API - 权限错误 [英] Google Cloud Text-to-Speech API - permission error

查看:76
本文介绍了Google Cloud Text-to-Speech API - 权限错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试按照以下说明设置 Google Cloud Text-to-Speech API - https://cloud.google.com/text-to-speech/docs/quickstart我已成功按照步骤 1-6 设置 Google SDK 并使用服务帐户凭据进行身份验证.但是,当我尝试运行用于合成语音的示例 HTTP 请求时,我收到以下错误:

I am attempting to set up Google Cloud Text-to-Speech API following these instructions - https://cloud.google.com/text-to-speech/docs/quickstart I have successfully followed steps 1-6 for setting up Google SDK and authenticating with service account credentials. However, when I attempt to run the sample HTTP request for synthesising speech I receive the following error:

Cloud Text-to-Speech API 之前未在项目 usable-auth-library 中使用或已禁用.通过访问 https 启用它://console.developers.google.com/apis/api/texttospeech.googleapis.com/overview?project=usable-auth-library 然后重试.

Cloud Text-to-Speech API has not been used in project usable-auth-library before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/texttospeech.googleapis.com/overview?project=usable-auth-library then retry.

当点击错误消息中的链接时,它会转到以下页面:

When following the link in the error message it leads to the following page:

APItexttospeech.googleapis.com"不存在或您无权访问它.

The API "texttospeech.googleapis.com" doesn't exist or you don't have permission to access it.

感谢您的帮助.

推荐答案

我使用 API 密钥而不是 Google 在其文档中推荐的服务帐户密钥更容易集成到大多数平台中.

I easier to integrate in most plarforms using the API key instead of the service account key that Google recomends on their docs.

这些是获取 API 密钥所需的所有步骤

These are all the steps you need to get to the the API key

  1. Cloud 中创建项目(或使用现有项目)控制台.
  2. 确保为您的项目启用计费.
  3. 启用Text-to-Speech API.
  4. 创建API 密钥.

您可能只需要最后一步(如果您像您所说的那样正确地执行了所有步骤).

You'll probably only need the last step (if you followed all the steps correctly like you said).

然后你可以像这样使用 curl 命令

And then you can use the curl command like so

Curl -H "X-Goog-Api-Key: PUT_YOUR_API_KEY_HERE" \
  -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-Standard-A',
      'ssmlGender':'FEMALE'
    },
    'audioConfig':{
      'audioEncoding':'MP3'
    }
  }" "https://texttospeech.googleapis.com/v1beta1/text:synthesize" > synthesize-text.txt

这篇关于Google Cloud Text-to-Speech API - 权限错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆