简体   繁体   English

无法设置语音转文本 GCP api

[英]can't set up speech-to-text GCP api

I've been struggling to transcribe audio to text in Python.我一直在努力用 Python 将音频转录为文本。 Here's what I've done so far:这是我到目前为止所做的:

  1. Got a GCP billing account with a 90-day free trial获得了 90 天免费试用的 GCP 结算帐号
  2. Enabled the Google Cloud speech-to-text API启用 Google Cloud 语音转文本 API
  3. Downloaded a JSON file and set it as an environment variable (always have to call os.environ["GOOGLE_APPLICATION_CREDENTIALS"]='C:\\Python\\Python37\\Lib\\site-packages\\google\\Borster.json' in Jupyter, otherwise when I do it with set in the cmd, the variable disappears when I reopen cmd)下载了一个 JSON 文件并将其设置为环境变量(在 Jupyter 中总是必须调用os.environ["GOOGLE_APPLICATION_CREDENTIALS"]='C:\\Python\\Python37\\Lib\\site-packages\\google\\Borster.json' ,否则当我在cmd中set ,当我重新打开cmd时变量消失
  4. I then noticed that I " cannot import name 'enums' from 'google.cloud.speech_v1p1beta1' ".然后我注意到我“无法从‘google.cloud.speech_v1p1beta1’导入名称‘enums’ ”。 So, the only thing I could do as a bypass was to replace the speech_v1p1beta1 folder with another one I found on the web that did have the enums.py file.所以,我可以做一个旁路的唯一的事情就是用另一个我认为确实有在网络上找到替换speech_v1p1beta1文件夹enums.py文件。
  5. Then, I made a bucket called 'callsaudiofiles21' in Google Storage, but still couldn't access it, because it was giving me the 403 GET https://storage.googleapis.com/storage/v1/b?project=i-enterprise-294210&projection=noAcl&prettyPrint=false : borster-659@i-enterprise-294210.iam.gserviceaccount.com does not have storage.buckets.list access to the Google Cloud project.然后,我在 Google Storage 中创建了一个名为“callsaudiofiles21”的存储桶,但仍然无法访问它,因为它给了我403 GET https://storage.googleapis.com/storage/v1/b?project=i- Enterprise-294210&projection=noAcl&prettyPrint=false :borster-659@i-enterprise-294210.iam.gserviceaccount.com 没有对 Google Cloud 项目的 storage.buckets.list 访问权限。
  6. I then did some research and it turns out I can't list the buckets because I haven't assigned the proper role to my account.然后我做了一些研究,结果我无法列出存储桶,因为我没有为我的帐户分配适当的角色 So I did,所以我做了, 在此处输入图片说明 ...but still getting the same error. ...但仍然得到同样的错误。

I haven't been programming for too long so I'm very confused with this API and this whole Google Cloud platform in general.我编程的时间不长,所以我对这个 API 和整个谷歌云平台非常困惑。 If there's anything else helpful I could share, please tell me.如果还有其他有用的东西我可以分享,请告诉我。 I've been struggling for 3 days but nothing going.我已经挣扎了 3 天,但没有任何进展。

The service account that you create does not have permission to your bucket.您创建的服务帐号无权访问您的存储桶。 The error message states that the the list permission is missing.该错误消息指出缺少list权限。

The solution is to use the Google Cloud Console (or the CLI) and add the appropriate role to the service account.解决方案是使用 Google Cloud Console(或 CLI)并将适当的角色添加到服务帐户。

Granting, changing, and revoking access to resources 授予、更改和撤销对资源的访问权限

Select one of the Cloud Storage roles listed on this page:选择此页面上列出的 Cloud Storage 角色之一:

IAM roles for Cloud Storage Cloud Storage 的 IAM 角色

The service account will need roles/storage.objectViewer服务帐户将需要roles/storage.objectViewer

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

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