简体   繁体   English

Google Cloud语音识别权限被拒绝错误

[英]Google Cloud Speech Recognition Permission Denied Error

I am trying to do Google cloud Speech Recognition for personal assistant built on python. 我正在尝试为基于python的个人助理执行Google云语音识别。 I have a service account and also have setup GOOGLE_ACCOUNT_CREDENTIALS and also have enabled the API. 我有一个服务帐户,还设置了GOOGLE_ACCOUNT_CREDENTIALS,还启用了API。 But its not working. 但是它不起作用。 This is the example code from official page. 这是官方页面上的示例代码。

from google.cloud import speech
client = speech.SpeechClient()
results = client.recognize(
    audio=speech.types.RecognitionAudio(
        uri='gs://my-bucket/recording.flac',
    ),
    config=speech.types.RecognitionConfig(
        encoding='LINEAR16',
        language_code='en-US',
        sample_rate_hertz=44100,
    ),
)
for result in results:
    for alternative in result.alternatives:
        print('=' * 20)
        print('transcript: ' + alternative.transcript)
        print('confidence: ' + str(alternative.confidence))

Error: 错误:

(base) C:\Users\mnauf>C:/Users/mnauf/Anaconda3/python.exe d:/Programming/python/mic.py
Traceback (most recent call last):
  File "C:\Users\mnauf\Anaconda3\lib\site-packages\google\api_core\grpc_helpers.py", line 59, in error_remapped_callable
    return callable_(*args, **kwargs)
  File "C:\Users\mnauf\Anaconda3\lib\site-packages\grpc\_channel.py", line 533, in __call__
    return _end_unary_response_blocking(state, call, False, None)
  File "C:\Users\mnauf\Anaconda3\lib\site-packages\grpc\_channel.py", line 467, 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":"@1543062997.122000000","description":"Error received from peer","file":"src/core/lib/surface/call.cc","file_line":1017,"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 "d:/Programming/python/mic.py", line 10, in <module>
    sample_rate_hertz=44100,
  File "C:\Users\mnauf\Anaconda3\lib\site-packages\google\cloud\speech_v1\gapic\speech_client.py", line 227, in recognize
    request, retry=retry, timeout=timeout, metadata=metadata)
  File "C:\Users\mnauf\Anaconda3\lib\site-packages\google\api_core\gapic_v1\method.py", line 139, in __call__
    return wrapped_func(*args, **kwargs)
  File "C:\Users\mnauf\Anaconda3\lib\site-packages\google\api_core\retry.py", line 260, in retry_wrapped_func
    on_error=on_error,
  File "C:\Users\mnauf\Anaconda3\lib\site-packages\google\api_core\retry.py", line 177, in retry_target
    return target()
  File "C:\Users\mnauf\Anaconda3\lib\site-packages\google\api_core\timeout.py", line 206, in func_with_timeout
    return func(*args, **kwargs)
  File "C:\Users\mnauf\Anaconda3\lib\site-packages\google\api_core\grpc_helpers.py", line 61, 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

在行uri='gs://my-bucket/recording.flac',使用要转换的文件将路径更改为您自己的存储桶,因为该存储桶确实存在,因为存储桶名称在GCP中是唯一的,并且因此,您无权使用您的服务帐户密钥进行访问。

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

相关问题 Google Cloud Speech API实时识别 - Google Cloud Speech API real time recognition 终端上使用Python的云异步语音识别错误 - Cloud Asynchronous Speech Recognition Error with Python on terminal Google语音识别API凭据错误 - Google speech recognition API credentials error 如何在 Google App Engine (python) 中导入 Google Cloud 语音识别 - How to import google cloud speech recognition in Google App Engine (python) 替代语言代码(流媒体)谷歌云上的语音识别值错误 - Speech Recognition ValueError on Alternative Language Codes (Streaming) Google CLoud *** ConnectionError:尝试将文件上传到Google Cloud Storage时(“连接已中止。”,错误(13,“权限被拒绝”)) - *** ConnectionError: ('Connection aborted.', error(13, 'Permission denied')) when trying to upload files to Google Cloud Storage 我试用时,Google语音识别模块会抛出错误 - Google Speech Recognition module throws error when I try it out python中谷歌语音识别的“音频数据必须是音频数据”错误 - 'Audio data must be audio data' error with google speech recognition in python 语音请求错误中的Google的Cloud Speech API异常 - Google's Cloud speech API Exception in speech request error 谷歌语音识别拒绝连接 - Connection Refused by Google Speech Recognition
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM