小编fa2*_*212的帖子

Google Cloud 403 错误所属项目的结算帐号在缺席状态下被禁用

我在 Google Cloud 上启用了一个项目、计费和 Cloud Speech to Text API。然后我下载了一个 .json 文件。然后我尝试在 PyCharm 中执行这个基本代码。

    import os
    os.environ['GOOGLE_APPLICATION_CREDENTIALS'] ="instant-medium-282.json"
    
    from google.cloud import speech_v1
    from google.cloud.speech_v1 import enums
    
    client = speech_v1.SpeechClient()
    
    encoding = enums.RecognitionConfig.AudioEncoding.FLAC
    sample_rate_hertz = 44100
    language_code = 'en-US'
    config = {'encoding': encoding, 'sample_rate_hertz': sample_rate_hertz, 'language_code': language_code}
    uri = 'gs://bucket_name/file_name.flac'
    audio = {'uri': uri}
    
    response = client.recognize(config, audio)
Run Code Online (Sandbox Code Playgroud)

但是,我不断收到此错误:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/google/api_core/grpc_helpers.py", line 57, in error_remapped_callable
    return callable_(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/grpc/_channel.py", line 826, in __call__
    return _end_unary_response_blocking(state, call, …
Run Code Online (Sandbox Code Playgroud)

google-cloud-platform google-cloud-billing google-speech-to-text-api

12
推荐指数
2
解决办法
2万
查看次数