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

PermissionDenied: 403 error when trying to run async Google Cloud Speech async transcribe

我在尝试对 google 云上托管的 .flac 文件进行 运行 异步 t运行 脚本请求时遇到以下错误。

$ 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

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

您需要制作文件publicly readable。将权限设置为 allUsers 后,您将能够在您的请求中使用您的文件。