Google cloud storage PermissionDenied:403尝试运行异步Google云语音异步转录时出错

Google cloud storage PermissionDenied:403尝试运行异步Google云语音异步转录时出错,google-cloud-storage,google-cloud-speech,Google Cloud Storage,Google Cloud Speech,我在尝试对托管在google cloud上的.flac文件运行异步转录请求时遇到以下错误 $ python3 transcribe_async.py gs://[file].flac Traceback (most recent call last): File "[]/anaconda3/lib/python3.6/site-packages/google/api_core/grpc_helpers.py", line 54, in error_remapped_callable

我在尝试对托管在google cloud上的.flac文件运行异步转录请求时遇到以下错误

$ python3 transcribe_async.py gs://[file].flac
Traceback (most recent call last):
  File "[]/anaconda3/lib/python3.6/site-packages/google/api_core/grpc_helpers.py", line 54, in error_remapped_callable
    return callable_(*args, **kwargs)
  File "[]/anaconda3/lib/python3.6/site-packages/grpc/_channel.py", line 514, in __call__
    return _end_unary_response_blocking(state, call, False, None)
  File "[]/anaconda3/lib/python3.6/site-packages/grpc/_channel.py", line 448, in _end_unary_response_blocking
    raise _Rendezvous(state, None, None, deadline)
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with:
    status = StatusCode.PERMISSION_DENIED
    details = "The caller does not have permission"
    debug_error_string = "{"created":"@1533912393.258761000","description":"Error received from peer","file":"src/core/lib/surface/call.cc","file_line":1095,"grpc_message":"The caller does not have permission","grpc_status":7}"
>

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "transcribe_async.py", line 105, in <module>
    transcribe_gcs(args.path)
  File "transcribe_async.py", line 83, in transcribe_gcs
    operation = client.long_running_recognize(config, audio)
  File "[]/anaconda3/lib/python3.6/site-packages/google/cloud/speech_v1/gapic/speech_client.py", line 284, in long_running_recognize
    request, retry=retry, timeout=timeout, metadata=metadata)
  File "[]/anaconda3/lib/python3.6/site-packages/google/api_core/gapic_v1/method.py", line 139, in __call__
    return wrapped_func(*args, **kwargs)
  File "[]/anaconda3/lib/python3.6/site-packages/google/api_core/retry.py", line 260, in retry_wrapped_func
    on_error=on_error,
  File "[]/anaconda3/lib/python3.6/site-packages/google/api_core/retry.py", line 177, in retry_target
    return target()
  File "[]/anaconda3/lib/python3.6/site-packages/google/api_core/timeout.py", line 206, in func_with_timeout
    return func(*args, **kwargs)
  File "[]/anaconda3/lib/python3.6/site-packages/google/api_core/grpc_helpers.py", line 56, in error_remapped_callable
    six.raise_from(exceptions.from_grpc_error(exc), exc)
  File "<string>", line 3, in raise_from
google.api_core.exceptions.PermissionDenied: 403 The caller does not have permission
$python3 transcribe\u async.py gs://[file].flac
回溯(最近一次呼叫最后一次):
文件“[]/anaconda3/lib/python3.6/site packages/google/api\u core/grpc\u helpers.py”,第54行,错误\u重新映射\u可调用
返回可调用函数(*args,**kwargs)
文件“[]/anaconda3/lib/python3.6/site packages/grpc/_channel.py”,第514行,在调用中__
返回\u结束\u一元\u响应\u阻塞(状态、调用、错误、无)
文件“[]/anaconda3/lib/python3.6/site packages/grpc/_channel.py”,第448行,一元响应
提升集合点(状态,无,无,截止日期)
grpc._通道_会合点:
上述异常是以下异常的直接原因:
回溯(最近一次呼叫最后一次):
文件“transcribe_async.py”,第105行,在
转录gcs(参数路径)
文件“transcribe_async.py”,第83行,在transcribe_gcs中
operation=client.long\u running\u recognize(配置、音频)
文件“[]/anaconda3/lib/python3.6/site packages/google/cloud/speech\u v1/gapic/speech\u client.py”,第284行,长时间运行
请求,重试=重试,超时=超时,元数据=元数据)
文件“[]/anaconda3/lib/python3.6/site packages/google/api_core/gapic_v1/method.py”,第139行,在调用中__
返回包装函数(*args,**kwargs)
文件“[]/anaconda3/lib/python3.6/site packages/google/api\u core/retry.py”,第260行,在retry\u wrapped\u func中
on_错误=on_错误,
文件“[]/anaconda3/lib/python3.6/site packages/google/api_core/retry.py”,第177行,在retry_目标中
返回目标()
文件“[]/anaconda3/lib/python3.6/site packages/google/api_core/timeout.py”,第206行,func_格式,带_timeout
返回函数(*args,**kwargs)
文件“[]/anaconda3/lib/python3.6/site packages/google/api\u core/grpc\u helpers.py”,第56行,错误\u重新映射\u可调用
六、从(例外情况。从grpc错误(exc),exc)
文件“”,第3行,从
google.api_core.exceptions.PermissionDenied:403调用方没有权限

我在.zshrc文件中添加了一个指向服务帐户json的导出语句,我通过浏览器添加了我自己、服务帐户电子邮件以及项目所有者和编辑器作为云存储桶的所有者,我运行了
gcloud auth activate service account--key file=“[].json”
,但没有任何帮助。我忘了什么?非常感谢您的帮助

您需要创建您的文件。一旦您为allUsers设置了权限,您就可以在请求中使用您的文件。

@F10,如果您不想公开共享您的文件,该怎么办?在大多数应用程序中,您希望保护您的数据,因此您需要首先让google speech to text API进行身份验证,例如,使用服务器密钥。问题是-如何做到这一点?您可以向用于执行API请求的服务帐户授予读者权限,而无需使其公开可读。您可以使用以下gsutil命令向服务帐户授予读取您的文件的权限
gsutil acl ch-u:R gs://